<?xml version="1.0"?>
<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="untitled1"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
<!-- extract android style -->
<!-- available android:values :
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
<!-- extract android style -->
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- %%INSERT_PERMISSIONS -->
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<!-- %%INSERT_FEATURES -->
</manifest>
新增:0919
Qt for Android项目,在编译运行后生成的文件夹说明:
在编译路径下会生成名为Android的文件夹,这个文件夹包含了所有Android相关的配置、源码等文件。
src文件夹,包含了项目的所有包(java对项目中类的管理方式,是一种命名方式)
gen文件夹,是ADT(Android Development Tools)自动生成,一般包含一个R.java文件,此文件根据src文件夹中资源生成,存放res中资源文件索引
assets文件夹作用与qrc类似,相当于一个虚拟文件系统,里面的资源文件会直接打包进APK包里,不会映射到R.java中,应用启动后可以通过AssetManager(java类)访问,也可以使用"assets://"前缀来访问资源
bin文件夹,存放编译结果,最终生成的APK就在里面
libs文件夹,存放Android应用依赖的外部库文件,可以是java源文件编译的.jar也可以是C/C++源文件编译的.so文件
res文件夹,资源文件,映射到R.java中。下又分为drawable(可绘制资源,图片等)、layout(布局文件,可由布局文件直接生成界面,Android的特殊文件类似于qml文件)、value(字符串、颜色值、数值等)。
Android应用开发有4个组件,Activity(活动)、Service(服务)、Connect Provider(服务提供者)、Broadcast Receiver(广播接收器)。
AndroidManifest文件中就对这些组件配有专门的节点进行描述,同时可以使用Intent过滤器和权限来确定这些组件之间以及组件和其他应用是如何交互的。
1、manifest 根节点,必须包括一个application节点
package属性用于设置应用进程的默认名称,也是默认包名;
xmlns:android属性用于设置android命名空间,一般为http://schemas.android.com/apk/res/android,这样使得Android中各种标准属性能在文件中使用,提供了大部分元素中的数据;
android:versionName属性设置APP的版本号,用于提供给用户版本说明
android:versionCode属性是设置设备升级版本识别号,保存APP更新次数,必须是数值型,例如第一版为1,之后二三版为2、3
android:installLocation属性设置程序安装位置,有三个值
internalOnly—APK必须安装到内部存储空间。并且安装之后,不能将程序移动到SD卡上。
auto—系统会根据存储空间去选择将APK安装在内部存储空间还是SD卡上。安装之后,可以在内部存储空间和SD卡之间移动。
preferExternal—系统会优先考虑将APK安装到SD卡上,如果SD存储已满,也会安装到内部存储上。
2、application标签
android:hardwareAccelerated属性设置程序中所有Activity和View对象启用硬件加速渲染,true启动;false不启动。默认为true
andriod:name属性设置application子类的实现,应用程序启动时,这个类在其他组件模块之前实例化,这个属性设置值采用完整的java类名;可选项,如果没有自己的子类,默认"org.qtproject.qt5.android.bindings.QtApplication"这个基本的Application实例,及org/qtproject/qt5/android/bindings/QtApplication.java中定义的QtApplication类。
android:lable属性是一个标签(桌面图标下面的文件以及应用启动后上面的标题),默认为%%INSERT_APP_NAME%%
3、activity标签
android:configChanges属性设置了需要Activity自己处理的配置变化项,这些设置的项如果发生变化,则要进行自我处理。默认情况,运行时配置变化发生时,Activity会关闭并重启,如果设置了这些配置变化项,则不会重启Activity。
默认值:"orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
orientation—屏幕方向发生变化,要自我处理,例如旋转屏幕
uiMode—用户界面发生变化时,要自我处理(这里的变化方式不太明白)
screenLayout—屏幕布局发生变化时,要自我处理,例如采用不同的显示模式时
smallestScreenSize—设备物理尺寸发生变化时,要自我处理,例如显示在不同显示器上
layoutDirection—布局方向发生变化时,要自我处理(这里的变化方式不太明白)
locale—语言环境变化时,要自我处理,例如选择不同的语种类型
fontScale—字体大小变化时,要自我处理,例如选择不同的字体大小设置
keyboard—键盘类型变化时,要自我处理,例如插入外接键盘
keyboardHidden—键盘的可用性发生变化时,要自我处理,例如启用了其他新接入的键盘
navigation—导航类型变化时,要自我处理
android:name属性设置了这个Activity对应的类名,默认值"org.qtproject.qt5.android.bindings.QtActivity",及org/qtprojects/qt5/android/bingings/QtActivity.java中定义的QtActivity类。
android:lable属性是标签,默认值%%INSERT_APP_NAME%%
android:screenOrientation属性设置Activity在设备上的显示方向,默认值"unspecified"
unspecified—默认值,由系统来选择方向
user—使用用户当前首选的方向
sensor—显示的方向是由设备的方向传感器来决定的,但是这个设置可能不能满足4个方向的旋转,可使用fullSensor
fullSensor—显示方向4个方向的旋转
noSensor—不会按照方向传感器进行选准
另外还有一些横向、纵向旋转的设置,可以自行查找了解一下。
android:launchMode属性设置如何启动Activity的指令。默认值"singleTop",有四个值供选择
standard—Activity能够实例化多次,每次需要创建新的Intent对象
singleTop—Activity能够实例化多次,不一定需要创建新的Intent对象
singleTask—Activity只能启动一次,允许其他Activity作为它的一部分运行
singleInstance—Activity只能启动一次,不允许其他Activity作为它的部分运行
新增:0919
android:targetActivity(其实是activity-alias的属性但是在我的实际代码中在Activity用到)属性指定了目标Activity,类似于Activity标签中的name属性,相当于别名
android:process属性设置Activity应该运行的那个进程的名字,通常情况应用程序的所有组件都运行在这个程序所创建的一个默认的进程中,它跟应用程序的包有相同名字,其中<application>的process属性可以覆盖所有组件提供一个相同的默认值,但是每个组件都能够覆盖整个默认值,允许应用分离到不同线程中。
3、service标签,这个标签用于声明一个服务(Service类的子类)作为应用的组件之一,和Activity不一样,这个组件没有可见的用户界面,可以将Activity看做用户界面这种组件,而Service被用于实现后台操作,或者是提供给其他应用操作的通信API接口。
android:name属性设置实现该组件的子类的类名,可以是完整的java类名,例如org.manager.afs.AfsProvierService,也可以使用缩写.AfsProvierService,这个属性没有默认值必须要设置。
android:permission属性设置绑定或者启动服务的应用必须要的权限,如果这个属性没被设置,那么通过<application>标签的permission属性所设定的权限就会适用于该服务,如果application也没有设置,则这个服务不受权限保护。
4、intent-filter标签,用于指定Activity、Service或Broadcast Receiver能够响应的Intent对象的类型,相当于过滤器
5、action标签,给Intent过滤器添加一个操作,一个<intent-filter>里面必须包含一个或者多个action,如果一个都没有,就不会有Intent对象通过过滤器。
android:name属性设置操作的名称,一般用ACTION_string常量定义标准操作,关联这些操作和这个属性的时候,需要将ACTION_转换成"android.intent.action.",例如ACTION_MAIN->action.intent.action.MAIN;对于自定义的操作,可以使用包名来替换,确保唯一性,例如org.qtproject.example.GETTINGDAT。
6、category标签,给Intent过滤器添加一个分类名称
android:name属性定义分类的名称,标准的分类一般用CATEGORY_name常量定义,关联这个定义和这个属性的时候,需要将CATEGORY_name转换成"andoid.intent.category.",例如CATEGORY_LAUNCHER->andoid.intent.category.LAUNCHER;自定义分类可使用报名来替代,如action标签。
7、meta-data标签,用name-value对的方式给父组件提供数据,一个组件的元素能够包含任意多个<meta-data>子元素,所有这些meta元素中定义的值会被集合到一个对象中,并且提供给组件。
android:name属性设置应用的唯一名称,使用java的命名规则可确保命名的唯一性,例如android.app.lib_name
android:value属性给这个name项分配一个值,可以分配不同的Int、String等类型,不同类型的值获取方式不同,例如getInt()、getString()
android:resource属性定义了要引用的资源,资源的ID会进行关联(这里的获取还不太清楚)
8、uses-sdk标签,定义APK能够运行的版本
android:minSdkVersion属性设置能够运行APK的最小sdk版本。如果没有设定的话,默认是1。
android:targetSdkVersion属性设置了运行APK的目标的API级别。如果没有设定的话,默认等于minSdkVersion。
另外还有一个android:maxSdkVersion属性,设置能够运行APK的最大sdk版本,一般这个属性不设置,因为可能导致应用不能在升级后的平台使用
9、supports-screens标签,控制应用支持的屏幕尺寸,并且针对当出现比应用程序支持的屏幕还要大的屏幕时,启动屏幕兼容模式
android:largeScreens属性设置是否支持较大外形的屏幕,默认为true
android:normalScreens属性设置是否支持普通外形的屏幕,默认为true
android:anyDensity属性设置是否包含使用任意外形屏幕的资源,默认为true
android:smallScreens属性设置是否支持较小外形的屏幕,默认为true
10、还有很多其他的标签,不过目前还未遇到,以后遇到在继续进行补充;感觉应该就是java的AndroidManifest.xml文件一样的配置。只是C++的程序员应该不怎么了解java还需要继续学习。