- 語法:
<instrumentation android:functionalTest=["true" | "false"] android:handleProfiling=["true" | "false"] android:icon="drawable resource" android:label="string resource" android:name="string" android:targetPackage="string" android:targetProcesses="string" />
- 包含於:
<manifest>
- 說明:
- 宣告可讓您的
Instrumentation
類別 監控應用程式與系統的互動。Instrumentation
物件即會在應用程式的任何元件之前例項化。 - 屬性:
android:functionalTest
- 指出
Instrumentation
類別是否會做為功能測試執行。 如果是,則為true
;如果不是,則為false
。 預設值為false
。 android:handleProfiling
- 指定
Instrumentation
物件是否會開啟剖析功能以及 關閉。如果這能判定剖析的開始時間,則設為true
。 如果剖析作業全程持續進行,則會傳回false
。 備用資源true
值可讓物件指定剖析作業 執行特定作業預設值為false
。 android:icon
- 代表
Instrumentation
類別的圖示。此屬性 必須設為對某可繪製資源的參照。 android:label
- 使用者可理解的
Instrumentation
類別標籤。標籤 可設定為原始字串或對字串資源的參照。 android:name
Instrumentation
子類別的名稱。請使用完整的類別名稱,例如com.example.project.StringInstrumentation
。不過為了精簡起見 如果名稱的第一個字元是半形句號,則會附加至套件 在<manifest>
元素中指定的名稱。這項屬性沒有預設值。您必須指定名稱。
android:targetPackage
Instrumentation
物件執行的應用程式 下定決心以應用程式指派的套件名稱做為識別依據<manifest>
元素的資訊清單檔案。android:targetProcesses
Instrumentation
物件的處理程序 適合所有玩家逗號分隔清單表示檢測作業已執行 並依據這些具體程序進行調整"*"
值表示 系統會針對以下項目中定義的應用程式所有程序執行檢測作業:android:targetPackage
。如果資訊清單中未提供這個值,系統會執行檢測作業 套用至應用程式中定義的應用程式主要程序
android:targetPackage
。這是在 API 級別 26 中新增的屬性。
- 導入版本:
- API 級別 1
<檢測>
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# <instrumentation\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cinstrumentation android:functionalTest=[\"true\" | \"false\"]\n android:handleProfiling=[\"true\" | \"false\"]\n android:icon=\"drawable resource\"\n android:label=\"string resource\"\n android:name=\"string\"\n android:targetPackage=\"string\"\n android:targetProcesses=\"string\" /\u003e\n ```\n\ncontained in:\n: [\u003cmanifest\u003e](/guide/topics/manifest/manifest-element)\n\ndescription:\n: Declares an [Instrumentation](/reference/android/app/Instrumentation) class that lets you\n monitor an application's interaction with the system. The `Instrumentation`\n object is instantiated before any of the application's components.\n\nattributes:\n:\n\n `android:functionalTest`\n : Whether the `Instrumentation` class runs as a functional test.\n This is `true` if it does and `false` if not. The\n default value is `false`.\n\n `android:handleProfiling`\n : Whether the `Instrumentation` object turns profiling on and\n off. This is `true` if it determines when profiling starts and\n stops and `false` if profiling continues the entire time it is\n running. A value of `true` enables the object to target profiling\n at a specific set of operations. The default value is `false`.\n\n `android:icon`\n : An icon that represents the `Instrumentation` class. This attribute\n must be set as a reference to a drawable resource.\n\n `android:label`\n : A user-readable label for the `Instrumentation` class. The label\n can be set as a raw string or a reference to a string resource.\n\n `android:name`\n : The name of the `Instrumentation` subclass.\n Use a fully qualified class name, such as\n `com.example.project.StringInstrumentation`. However, as a shorthand,\n if the first character of the name is a period, it is appended to the package\n name specified in the [\u003cmanifest\u003e](/guide/topics/manifest/manifest-element) element.\n\n\n There is no default. The name must be specified.\n\n `android:targetPackage`\n : The application that the `Instrumentation` object runs\n against. An application is identified by the package name assigned in its\n manifest file by the `\u003cmanifest\u003e` element.\n\n `android:targetProcesses`\n\n : The processes that the `Instrumentation` object\n runs against. A comma-separated list indicates that the instrumentation runs\n against those specific processes. A value of `\"*\"` indicates that the\n instrumentation runs against all processes of the app defined in\n `android:targetPackage`.\n\n If this value isn't provided in the manifest, the instrumentation runs\n only against the main process of the app defined in\n `android:targetPackage`.\n\n This attribute was added in API level 26.\n\nintroduced in:\n: API level 1"]]