Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

Android Manifest 中 <instrumentation> 元素用法詳解

編輯:關於 Android 程式設計

<instrumentation> 元素用於宣告 Instrumentation 類別,讓你能監控應用程式與系統之間的互動。以下是它的語法、屬性與使用說明。

語法

<instrumentation
    android:functionalTest=["true" | "false"]
    android:handleProfiling=["true" | "false"]
    android:icon="drawable resource"
    android:label="string resource"
    android:name="string"
    android:targetPackage="string" />

父元素

<manifest>

說明

Instrumentation 類別的物件會在應用的所有元件初始化之前先行建構,因此適合用於測試與監控用途。

屬性說明

  • android:functionalTest:指定 Instrumentation 類別是否作為功能性測試來執行,設為 true 則執行,否則不執行,預設值為 false。
  • android:handleProfiling:指定 Instrumentation 物件是否會開啟與關閉分析(Profiling)功能。設為 true 時,由 Instrumentation 物件自行決定分析的啟動與終止時機,可針對一組特定操作進行分析;設為 false 時,分析功能會持續到 Instrumentation 物件整個執行週期結束,預設值為 false。
  • android:icon:Instrumentation 類別呈現給使用者的圖示,必須設定為 Drawable 資源物件的參照。
  • android:label:使用者可讀的 Instrumentation 類別標籤,可設定為原生字串或字串資源的參照。
  • android:name:Instrumentation 子類別的名稱,應為完整的類別名稱(例如 "com.example.project.StringInstrumentation")。若名稱的第一個字元是點,則會接在 <manifest> 元素所指定的套件名稱之後。此屬性沒有預設值,必須明確指定。
  • android:targetPackage:Instrumentation 物件所要執行的目標應用,由該應用 manifest 檔中 <manifest> 元素所配置的套件名稱來指定。

出處:API Level 1

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