<?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還需要繼續學習。
