1page.title=應用程式宣示說明 2@jd:body 3 4<div id="qv-wrapper"> 5<div id="qv"> 6 7<h2>本文件內容</h2> 8<ol> 9<li><a href="#filestruct">宣示說明檔案結構</a></li> 10<li><a href="#filec">檔案轉換</a> 11<li><a href="#filef">檔案功能</a> 12 <ol> 13 <li><a href="#ifs">意圖篩選器</a></li> 14 <li><a href="#iconlabel">圖示和標籤</a></li> 15 <li><a href="#perms">權限</a></li> 16 <li><a href="#libs">程式庫</a></li> 17 </ol></li> 18</ol> 19</div> 20</div> 21 22<p> 23 每個應用程式的根目錄都必須包含 AndroidManifest.xml 檔案 (名稱要一字不差)。 24 <span itemprop="description">宣示說明檔案可向 Android 系統顯示應用程式的基本資訊,也就是系統在執行該應用程式的任何程式碼之前必須具備的資訊。 25 26 27</span> 宣示說明可執行下列動作: 28</p> 29 30<ul> 31<li>為應用程式的 Java 封裝命名。 32封裝名稱可當成應用程式的唯一識別碼使用。</li> 33 34<li>描述應用程式的元件 — 組成應用程式的 Activity、服務、廣播接收器和內容供應程式。 35 36為實作每個元件的類別命名以及發佈類別的功能 (例如,類別可處理的 {@link android.content.Intent 37Intent} 訊息)。 38這些宣告可讓 Android 系統瞭解元件為何以及可在哪些情況下啟動。 39</li> 40 41<li>決定代管應用程式元件的程序。</li> 42 43<li>宣告應用程式必須擁有哪些權限,才能存取 API 受保護的部分以及與其他應用程式互動。 44</li> 45 46<li>宣示說明亦可宣告其他項目必須擁有哪些權限,才能與應用程式的元件互動。 47</li> 48 49<li>列出可在應用程式執行時提供分析和其他資訊的 {@link android.app.Instrumentation} 類別。 50只有在應用程式開發及測試完成的情況下,宣示說明中才會顯示這些宣告;這些宣告會在應用程式發佈之前移除。 51 52</li> 53 54<li>宣告應用程式要求的最低 Android API 級別。 55</li> 56 57<li>列出應用程式必須連結的程式庫。</li> 58</ul> 59 60 61<h2 id="filestruct">宣示說明檔案結構</h2> 62 63<p> 64下圖顯示宣示說明檔案的一般結構和可納入其中的元素。 65每個元素和其所有屬性都會完全記錄在個別檔案中。 66如要查看任一元素的詳細資訊,只要按一下圖表中的元素名稱、圖表後方按字母順序列出的元素清單,或在他處提及的任何元素名稱。 67 68 69 70</p> 71 72<pre> 73<?xml version="1.0" encoding="utf-8"?> 74 75<a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a> 76 77 <a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"><uses-permission /></a> 78 <a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission /></a> 79 <a href="{@docRoot}guide/topics/manifest/permission-tree-element.html"><permission-tree /></a> 80 <a href="{@docRoot}guide/topics/manifest/permission-group-element.html"><permission-group /></a> 81 <a href="{@docRoot}guide/topics/manifest/instrumentation-element.html"><instrumentation /></a> 82 <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html"><uses-sdk /></a> 83 <a href="{@docRoot}guide/topics/manifest/uses-configuration-element.html"><uses-configuration /></a> <!-- ##api level 3## --> 84 <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><uses-feature /></a> <!-- ##api level 4## --> 85 <a href="{@docRoot}guide/topics/manifest/supports-screens-element.html"><supports-screens /></a> <!-- ##api level 4## --> 86 <a href="{@docRoot}guide/topics/manifest/compatible-screens-element.html"><compatible-screens /></a> <!-- ##api level 9## --> 87 <a href="{@docRoot}guide/topics/manifest/supports-gl-texture-element.html"><supports-gl-texture /></a> <!-- ##api level 11## --> 88 89 <a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a> 90 91 <a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a> 92 <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a> 93 <a href="{@docRoot}guide/topics/manifest/action-element.html"><action /></a> 94 <a href="{@docRoot}guide/topics/manifest/category-element.html"><category /></a> 95 <a href="{@docRoot}guide/topics/manifest/data-element.html"><data /></a> 96 <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"></intent-filter></a> 97 <a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data /></a> 98 <a href="{@docRoot}guide/topics/manifest/activity-element.html"></activity></a> 99 100 <a href="{@docRoot}guide/topics/manifest/activity-alias-element.html"><activity-alias></a> 101 <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a> . . . <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"></intent-filter></a> 102 <a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data /></a> 103 <a href="{@docRoot}guide/topics/manifest/activity-alias-element.html"></activity-alias></a> 104 105 <a href="{@docRoot}guide/topics/manifest/service-element.html"><service></a> 106 <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a> . . . <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"></intent-filter></a> 107 <a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data/></a> 108 <a href="{@docRoot}guide/topics/manifest/service-element.html"></service></a> 109 110 <a href="{@docRoot}guide/topics/manifest/receiver-element.html"><receiver></a> 111 <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a> . . . <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"></intent-filter></a> 112 <a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data /></a> 113 <a href="{@docRoot}guide/topics/manifest/receiver-element.html"></receiver></a> 114 115 <a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a> 116 <a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission /></a> 117 <a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data /></a> 118 <a href="{@docRoot}guide/topics/manifest/path-permission-element.html"><path-permission /></a> 119 <a href="{@docRoot}guide/topics/manifest/provider-element.html"></provider></a> 120 121 <a href="{@docRoot}guide/topics/manifest/uses-library-element.html"><uses-library /></a> 122 123 <a href="{@docRoot}guide/topics/manifest/application-element.html"></application></a> 124 125<a href="{@docRoot}guide/topics/manifest/manifest-element.html"></manifest></a> 126</pre> 127 128<p> 129下方按字母順序列出可出現在宣示說明檔案中的所有元素。 130只有這些才是符合資格的元素,您無法新增自己的元素或屬性。 131 132</p> 133 134<p style="margin-left: 2em"> 135<code><a href="{@docRoot}guide/topics/manifest/action-element.html"><action></a></code> 136<br/><code><a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a></code> 137<br/><code><a href="{@docRoot}guide/topics/manifest/activity-alias-element.html"><activity-alias></a></code> 138<br/><code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 139<br/><code><a href="{@docRoot}guide/topics/manifest/category-element.html"><category></a></code> 140<br/><code><a href="{@docRoot}guide/topics/manifest/data-element.html"><data></a></code> 141<br/><code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> 142<br/><code><a href="{@docRoot}guide/topics/manifest/instrumentation-element.html"><instrumentation></a></code> 143<br/><code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a></code> 144<br/><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code> 145<br/><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data></a></code> 146<br/><code><a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission></a></code> 147<br/><code><a href="{@docRoot}guide/topics/manifest/permission-group-element.html"><permission-group></a></code> 148<br/><code><a href="{@docRoot}guide/topics/manifest/permission-tree-element.html"><permission-tree></a></code> 149<br/><code><a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a></code> 150<br/><code><a href="{@docRoot}guide/topics/manifest/receiver-element.html"><receiver></a></code> 151<br/><code><a href="{@docRoot}guide/topics/manifest/service-element.html"><service></a></code> 152<br/><code><a href="{@docRoot}guide/topics/manifest/supports-screens-element.html"><supports-screens></a></code> <!-- ##api level 4## --> 153<br/><code><a href="{@docRoot}guide/topics/manifest/uses-configuration-element.html"><uses-configuration></a></code> <!-- ##api level 3## --> 154<br/><code><a href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><uses-feature></a></code> <!-- ##api level 4## --> 155<br/><code><a href="{@docRoot}guide/topics/manifest/uses-library-element.html"><uses-library></a></code> 156<br/><code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"><uses-permission></a></code> 157<br/><code><a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html"><uses-sdk></a></code> 158</p> 159 160 161 162 163<h2 id="filec">檔案轉換</h2> 164 165<p> 166某些轉換和規則通常適用於宣示說明中的所有元素與屬性: 167 168</p> 169 170<dl> 171<dt><b>元素</b></dt> 172<dd>只有 173<code><a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code> 與 174<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 是必要元素,務必顯示兩者且這些元素只能出現一次。 175雖然您至少必須顯示當中的一些元素,才能完成有意義的作業,但大部分其他元素可以出現數次或完全不出現。 176 177 178 179 180<p> 181如果可以的話,元素還可以包含其他元素。所有值並非當成元素內的字元資料使用,而是透過屬性設定。 182 183</p> 184 185<p> 186系統通常不會將位於相同層級的元素排序。例如, 187<code><a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a></code>、 188<code><a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a></code> 和 189<code><a href="{@docRoot}guide/topics/manifest/service-element.html"><service></a></code> 元素能以任何順序排列組合。 190( 191<code><a href="{@docRoot}guide/topics/manifest/activity-alias-element.html"><activity-alias></a></code> 元素是這項規則的例外狀況: 192由於它是 193<code><a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a></code> 的別名,因此必須跟在該元素的後面)。 194 195</p></dd> 196 197<dt><b>屬性</b></dt> 198<dd>形式上而言,所有屬性均為選用性質。不過,您必須為元素指定某些屬性,才能達到其目的。 199請使用本文件當成參考指南。 200真正的選用屬性會提及在缺少規格時要使用的預設值或狀態。 201 202 203<p>除了 204<code><a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code> 根元素的某些屬性以外,所有屬性名稱都是以前置詞 {@code android:}為開頭,例如 {@code android:alwaysRetainTaskState}。 205 206由於前置詞是通用的,因此按名稱參照屬性時,文件通常會加以省略。 207 208</p></dd> 209 210<dt><b>宣告類別名稱</b></dt> 211<dd>許多元素都會對應到 Java 物件,包括應用程式本身的元素 ( 212<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 元素) 與其主要元件:Activity (<code><a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a></code>)、服務 (<code><a href="{@docRoot}guide/topics/manifest/service-element.html"><service></a></code>)、廣播接收器 (<code><a href="{@docRoot}guide/topics/manifest/receiver-element.html"><receiver></a></code>) 以及內容供應程式 (<code><a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a></code>)。 213 214 215 216 217 218 219 220 221 222 223<p> 224如果您一如往常定義元件類別 ({@link android.app.Activity}、{@link android.app.Service}、 225{@link android.content.BroadcastReceiver} 及 {@link android.content.ContentProvider}) 般定義子類別,就會透過 {@code name} 屬性宣告子類別。 226 227該名稱必須包含完整的封裝指定名稱。 228例如,{@link android.app.Service} 子類別可能會以下列格式宣告: 229 230</p> 231 232<pre><manifest . . . > 233 <application . . . > 234 <service android:name="com.example.project.SecretService" . . . > 235 . . . 236 </service> 237 . . . 238 </application> 239</manifest></pre> 240 241<p> 242不過,採用速記法時,如果字串的第一個字元是句點,就會將字串附加到應用程式的封裝名稱 (如同由 243<code><a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code> 元素的 244<code><a href="{@docRoot}guide/topics/manifest/manifest-element.html#package">package</a></code> 屬性指定)。 245 246 247下列的指派結果會和上述相同: 248</p> 249 250<pre><manifest package="com.example.project" . . . > 251 <application . . . > 252 <service android:name=".SecretService" . . . > 253 . . . 254 </service> 255 . . . 256 </application> 257</manifest></pre> 258 259<p> 260啟動元件時,Android 會建立具名子類別的執行個體。如果未指定子類別,就會建立基本類別的執行個體。 261 262</p></dd> 263 264<dt><b>多個值</b></dt> 265<dd>如果可以指定多個值,該元素幾乎會一直重複,而不是在單一元素內列出多個值。 266例如,意圖篩選器能列出數種動作: 267 268 269<pre><intent-filter . . . > 270 <action android:name="android.intent.action.EDIT" /> 271 <action android:name="android.intent.action.INSERT" /> 272 <action android:name="android.intent.action.DELETE" /> 273 . . . 274</intent-filter></pre></dd> 275 276<dt><b>資源值</b></dt> 277<dd>有些屬性的值可以供使用者查看 — 例如 Activity 的標籤和圖示。 278您必須將這些屬性的值本地化,以便從資源或主題設定這些值。 279資源值是採用下列格式表示: 280</p> 281 282<p style="margin-left: 2em">{@code @[<i>package</i>:]<i>type</i>:<i>name</i>}</p> 283 284<p> 285其中的<i>package</i> 名稱可以省略 (如果資源所在的封裝和應用程式相同的話), 286 <i>type</i> 是指資源類型 — 例如「字串」或「可繪項目」 — 而 287 <i>name</i> 則是可識別特定資源的名稱。範例: 288 289</p> 290 291<pre><activity android:icon="@drawable/smallPic" . . . ></pre> 292 293<p> 294主題中的值會以類似的方式表示,但字首會是 '{@code ?}',而不是 '{@code @}': 295 296</p> 297 298<p style="margin-left: 2em">{@code ?[<i>package</i>:]<i>type</i>:<i>name</i>} 299</p></dd> 300 301<dt><b>字串值</b></dt> 302<dd>如果屬性值為字串,必須使用雙反斜線 ('{@code \\}')來溢出字元,例如 '{@code \\n}'表示換行字元,或 '{@code \\uxxxx}' 表示 Unicode 字元。 303 304</dd> 305</dl> 306 307 308<h2 id="filef">檔案功能</h2> 309 310<p> 311下列各節說明如何在宣示說明檔案中反映部分 Android 功能。 312 313</p> 314 315 316<h3 id="ifs">意圖篩選器</h3> 317 318<p> 319應用程式的核心元件 (即應用程式的 Activity、服務和廣播接收器) 是由 320 <i>意圖</i>啟動。意圖是一組資訊組合 ({@link android.content.Intent} 物件),用於說明要採取的動作 — 包括執行依據的資料、應執行動作的元件類別,以及其他相關的指示。 321 322 323Android 會找出適當的元件來回應意圖、視需要啟動元件的新執行個體,以及將意圖物件傳送給它。 324 325 326 327</p> 328 329<p> 330元件會通知其功能 (元件可回應的意圖類型),而通知途徑是 331 <i>意圖篩選器</i>。由於 Android 系統必須先瞭解元件能夠處理哪些意圖,才能啟動該元件,因此意圖篩選器在宣示說明中會指定為 332<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a></code> 元素。 333 334 335元件可包含的篩選器數目不拘,每個篩選器描述的功能各不相同。 336 337</p> 338 339<p> 340明確命名目標元件的意圖會啟動該元件,而不必使用篩選器。 341但未指定目標名稱的意圖,只有在其通過其中一個元件的篩選器後,才能啟動元件。 342 343 344</p> 345 346<p> 347如要瞭解意圖物件測試意圖篩選器的方式,請參閱<a href="{@docRoot}guide/components/intents-filters.html">意圖和意圖篩選器</a>。 348 349 350 351</p> 352 353 354<h3 id="iconlabel">圖示和標籤</h3> 355 356<p> 357許多元素都有可供小型圖示與文字標籤使用的 {@code icon} 和 {@code label} 屬性,而使用者可看到這些圖示和標籤。 358有些元素還包含可供較長說明文字使用的 359{@code description} 屬性,這個說明文字亦可顯示在螢幕上。 360例如,假設 361<code><a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission></a></code> 元素含有上述三種屬性,當系統詢問使用者是否將權限授予發出要求的應用程式時,可以將代表權限的圖示、該權限的名稱以及所需的描述全都向使用者顯示。 362 363 364 365 366</p> 367 368<p> 369在各種情況下,元件中設定的圖示和標籤會成為所有容器下層元素的預設 370{@code icon} 與 {@code label} 設定因此, 371<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 元素中設定的圖示和標籤會是應用程式各元件的預設圖示和標籤。 372 373同樣地,為元件 (例如 374<code><a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a></code> 元素) 設定的圖示和標籤會是元件的 375<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a></code> 元素預設值。 376 377 378如果 379<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 元素設有一個標籤,但 Activity 與其意圖篩選器並未設定該標籤,系統會將應用程式標籤視為 Activity 和意圖篩選器的標籤。 380 381 382 383</p> 384 385<p> 386每當執行篩選器通告的功能,要向使用者顯示元件時,就會將為意圖篩選器設定的圖示和標籤用來代表元件。 387 388例如,包含 389"{@code android.intent.action.MAIN}" 與 390"{@code android.intent.category.LAUNCHER}" 設定的篩選器會將某 Activity 宣告為啟動應用程式的 Activity,也就是應顯示在應用程式啟動器中的 Activity。 391 392因此,顯示在啟動器中的會是篩選器中設定的圖示和標籤。 393 394</p> 395 396 397<h3 id="perms">權限</h3> 398 399<p> 400單一 <i>權限</i> 是指一項限制,可限制某部分程式碼或裝置上資料的存取權。 401 系統會強制實施這項限制,以保護會遭到誤用而扭曲或損害使用者體驗的重要資料與程式碼。 402 403</p> 404 405<p> 406各項權限都是用不重複的標籤加以辨識。該標籤通常會指出受到限制的動作。 407例如,以下是 Android 定義的一些權限: 408 409</p> 410 411<p style="margin-left: 2em">{@code android.permission.CALL_EMERGENCY_NUMBERS} 412<br/>{@code android.permission.READ_OWNER_DATA} 413<br/>{@code android.permission.SET_WALLPAPER} 414<br/>{@code android.permission.DEVICE_POWER}</p> 415 416<p> 417單一功能最多只能利用一項權限來加以保護。 418</p> 419 420<p> 421如果應用程式需要存取受權限保護的功能,它必須在宣示說明中利用 422<code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"><uses-permission></a></code> 元素來宣告其需要該項權限。 423 424接著,要在裝置上安裝該應用程式時,安裝程式會檢查簽署該應用程式憑證的授權單位 (在某些情況下還會詢問使用者),然後決定是否授予要求的權限。 425 426 427如果授予權限,該應用程式就能夠使用受保護的功能。 428 429如果不授予權限,存取相關功能的嘗試就會失敗,但使用者不會收到任何通知。 430 431</p> 432 433<p> 434應用程式也能利用權限來保護自己的元件 (Activity、服務、廣播接收器和內容供應程式)。 435它能使用 Android 定義的任何權限 (列於 436{@link android.Manifest.permission android.Manifest.permission}) 或其他應用程式宣告的任何權限。 437 438此外,應用程式也能自行定義權限。新的權限是以 439<code><a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission></a></code> 元素宣告。 440 441例如,您可以利用下列權限保護 Activity: 442</p> 443 444<pre> 445<manifest . . . > 446 <permission android:name="com.example.project.DEBIT_ACCT" . . . /> 447 <uses-permission android:name="com.example.project.DEBIT_ACCT" /> 448 . . . 449 <application . . .> 450 <activity android:name="com.example.project.FreneticActivity" 451 android:permission="com.example.project.DEBIT_ACCT" 452 . . . > 453 . . . 454 </activity> 455 </application> 456</manifest> 457</pre> 458 459<p> 460請注意,在本範例中,不只以 461<code><a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission></a></code> 元素宣告 {@code DEBIT_ACCT} 權限,還使用 462<code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"><uses-permission></a></code> 元素來要求使用此權限。 463 464 465即使保護是由應用程式本身強制施行,還是必須要求使用該權限,應用程式的其他元件才能啟動受保護的 Activity。 466 467 468</p> 469 470<p> 471在相同的範例中,如果 {@code permission} 屬性設定為在別處宣告的權限 (例如 {@code android.permission.CALL_EMERGENCY_NUMBERS}),就不必再次使用 472<code><a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission></a></code> 元素來宣告。 473 474 475 476不過,還是必須利用 477<code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"><uses-permission></a></code> 來要求使用。 478</p> 479 480<p> 481 482<code><a href="{@docRoot}guide/topics/manifest/permission-tree-element.html"><permission-tree></a></code> 元素可為程式碼將定義的一組權限宣告命名空間。 483 484此外, 485<code><a href="{@docRoot}guide/topics/manifest/permission-group-element.html"><permission-group></a></code> 可為一組權限定義標籤 (以 486<code><a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission></a></code> 元素在宣示說明中宣告的權限或在別處宣告的權限)。 487 488它只會影響在向使用者呈現權限時的分組方式。 489 490<code><a href="{@docRoot}guide/topics/manifest/permission-group-element.html"><permission-group></a></code> 元素不會指定各權限所屬的群組,只會指定群組的名稱。 491 492只要將群組名稱指派給 493<code><a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission></a></code> 元素 494<code><a href="{@docRoot}guide/topics/manifest/permission-element.html#pgroup">permissionGroup</a></code> 的屬性,就能將權限放入群組中。 495 496 497 498</p> 499 500 501<h3 id="libs">程式庫</h3> 502 503<p> 504每款應用程式都會與預設的 Android 程式庫連結,該程式庫中包含的基本封裝可用於建置應用程式 (使用 Activity、Service、Intent、View、Button、Application、ContentProvider 等一般類別)。 505 506 507 508</p> 509 510<p> 511不過,有些封裝是存放在其專屬的程式庫中。如果您的應用程式使用來自這類封裝的程式碼,您必須明確要求與其建立連結。 512 513宣示說明必須包含個別的 514<code><a href="{@docRoot}guide/topics/manifest/uses-library-element.html"><uses-library></a></code> 元素,才能命名各個程式庫。 515(您可以在封裝的說明文件中找到程式庫名稱)。 516 517</p> 518