The AndroidManifest.xml File
【
安卓應用清單】
【
該文高度總結,初學須要屢次返回閱讀體味】
Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code. Among other things, the manifest does the following:html
【每一個安卓應用必須有一個 AndroidManifest.xml 文件,該文件位於開發目錄的主目錄中,這裏的 AndroidManifest.xml 就是開發目錄中清單的真實文件名。AndroidManifest.xml 文件包含了運行在安卓系統上的應用所必須的信息,下面是AndroidManifest.xml 文件的做用:】android
- It names the Java package for the application. The package name serves as a unique identifier for the application.
- 【讓開發者在裏面指定應用的Java包名稱,這個包名稱將做爲應用的惟一標識。】
- It describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which
Intent
messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched.
- 【它描述了應用由哪幾個組件,如活動、服務、廣播接受者、內容提供者,描述了實現這些組件的Java類,並列出他們的功能,好比說明他們能夠處理哪一個 Intent 信息。以上這些聲明就使安卓系統可以知道須要處理哪些東西,以及在什麼條件下處理。】
- It determines which processes will host application components.
- 【【 高級】AndroidManifest.xml 文件容許咱們決定應用或其中的組件須要跑在哪些進程中。 】
- It declares which permissions the application must have in order to access protected parts of the API and interact with other applications.
- 【AndroidManifest.xml 文件容許我們設置權限信息,代表咱們的應用能夠訪問哪些受保護的API,以及可以同哪些其餘應用交互,如內存管理軟件能夠設置權限來訪問手機的系統信息。】
- It also declares the permissions that others are required to have in order to interact with the application's components.
- 【AndroidManifest.xml 文件中權限的聲明是相互的,也就是說也能夠容許其餘應用在須要時訪問本身。】
- It lists the
Instrumentation
classes that provide profiling and other information as the application is running. These declarations are present in the manifest only while the application is being developed and tested; they're removed before the application is published.
- 【【 高級】 AndroidManifest.xml 文件容許開發者使用Instrumentation 類(監測類)得到應用運行的信息,通常是開發或測試階段使用,發佈時將會被去掉。 】
- It declares the minimum level of the Android API that the application requires.
- 【AndroidManifest.xml 文件會在建立時自動判斷並聲明應用須要的最低安卓API版本。 】
- It lists the libraries that the application must be linked against.
- 【 【 高級】 AndroidManifest.xml 文件會列出應用須要連接的外部庫。 】