Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
您现在的位置: Android教程網 >> Android系統教程 >  >> Android 技術 >> Android 開發 >> 初階開發

AndroidManifest.xml 剖析(二):application 節點的常見屬性

編輯:初階開發

本篇接續說明 AndroidManifest.xml 中的 application 分支。這個節點幾乎是所有元件的容器,其中有不少實用屬性值得我們深入了解,例如是否允許除錯的 android:debuggable、控制任務關聯性的 android:taskAffinity,以及指定程式主題的 android:theme。

我們常透過 FLAG_ACTIVITY_NEW_TASK 這個標記來開啟一個全新的任務,而想為整個程式指定統一的視覺主題時,就可以用 android:theme 指向一個主題資源檔。

此外,當程式會用到某些安全敏感的功能時,需要事先向系統申請權限,這可以透過 android:permission 來指定。要特別注意的是,不論是 service、activity、content provider 還是 receiver,這四種元件都必須宣告在 application 節點之內。

以下是 application 節點的完整屬性清單,可作為查閱參考:

<application android:allowClearUserData=["true" | "false"]
    android:allowTaskReparenting=["true" | "false"]
    android:debuggable=["true" | "false"]
    android:description="string resource"
    android:enabled=["true" | "false"]
    android:hasCode=["true" | "false"]
    android:icon="drawable resource"
    android:label="string resource"
    android:manageSpaceActivity="string"
    android:name="string"
    android:permission="string"
    android:persistent=["true" | "false"]
    android:process="string"
    android:taskAffinity="string"
    android:theme="resource or theme" >
    . . .
</application>

其中 android:debuggable 在正式發布前務必設為 false,以免洩漏除錯資訊;而 android:icon 與 android:label 則決定了程式在桌面與設定中顯示的名稱與圖示。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved