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 文件会列出应用须要连接的外部库。 】