1. 程式人生 > >關於QT for Android生成的AndroidManifest.xml學習說明

關於QT for Android生成的AndroidManifest.xml學習說明

normal mini please idg 大小 顯示 tmp 集合 insert

<?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>

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實例

  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"v,

  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作為它的部分運行

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

關於QT for Android生成的AndroidManifest.xml學習說明