The APK file is an installation file on Android. An android installation package contains all files related to the application.
The APK file is essentially a zip package, including the androidmanifest. xml file, application code (. Dex file), and resource file.
The androidmanifest. xml file is located in the root directory and mainly includes the following elements:
1. Package name: If the APK file name is not specified, the package will be named by the package name of the main java package in the application after compilation.
2. Certificate: Specifies the level of trust granted by the application. The current level of Authentication includes platform (system), shared, media, and custom application authentication.
3. Permission-group: Permission groups are defined to describe a group of permissions with common features.
4. Permission: Permission is used to describe whether a user has the right to do something. Permissions in the Android system are classified into normal, dangerous, signature, and signature or system ).
All predefined permissions in the system belong to different levels based on their roles. For normal and dangerous-level permissions, they are called low-level permissions. An application is granted. For other two-level permissions, they are called high-level permissions or system permissions. An application can apply for permissions only when it has platform-level authentication, when an application attempts to perform a restricted operation without permission, the application will be killed by the system.
5. Permission tree (permission-tree): The permission tree is set to manage a group of permissions in a unified manner, and the permission owner under the tree is declared to belong to the application. The system provides APIs for applications to dynamically add packagemanager. addpermission () at runtime ()
6. Use Permission (uses-permission): the permissions required by the application should be applied here. The applied permissions should be defined by the system or an application. Otherwise, the application is deemed invalid. Applications that use permissions must follow the permission granting conditions. applications that do not use platform authentication cannot apply for advanced permissions.
7. SDK (uses-SDK): identifies the SDK version for this application. This option can be ignored for highly compatible applications.
8. Application: The application is the top-level module in an Android Application. Each application can have only one application. If the application does not specify this module, A default application is enabled. The application is first loaded when it is started and remains in the entire runtime lifecycle of the application. Therefore, some initialization work is suitable for this module. The application element has many attributes. "persistent" indicates whether the application is resident in the memory, and "enable" indicates whether the application should be loaded currently.
9. Activity: activity is a child element of the application module during runtime and identifies a UI. An application can declare and implement zero to multiple runtime modules, including activity. The activity identifies which intent can be processed by adding intent-filter, and the intent is the main parameter for activity scheduling.
10. Receiver Er: the receiver er is also a sub-element of the application runtime. The receiver identifies the intent to be accepted by adding intent-filter. When an intent is received, the Receiver performs different processing based on the intent. When an intent is sent, all the registrants registered with the intent will receive the message, and the system will send the message in the order of registration by the processor in the system; when a receiver has multiple unreceived intents, the receiver receives the messages in the order in which the intents are sent.
11. Service: the service is also a sub-element of the application runtime, which belongs to the background module and runs for a long time after it is started, unless the service is stopped or the application process in which it is located is killed.
12. provider: provider is also the runtime word element of the application. Inheritance and contentprovider are structured access to user data managed by the application and encapsulation based on database operations. If an application allows an external application to access/manage its user data, provider is the best solution provided by the Android platform.
13. Activity-alias: alias of an existing activity.
14. Uses-Library: identifies the shared library required for application startup.
Androidmanifest. XML structure outline:
<Manifest> the root node of the file describes all the contents of the package. <uses-Permission> to request a security authorization, you must be granted this permission before your package can operate correctly. 0 ~ N <permission> declares a security authorization to restrict which applications can access the components and special mechanisms in your package. 0 ~ N <instrumentation> <Application> describes the root node of the application-level component in the package. this node can describe the global (and/or) default attributes of the application, such as labels, icons, themes, required authorizations, and so on. contains zero or one such node <activity> activity is the most important mechanism for user interaction. when an application runs, the first screen displayed by the user is activity, and the vast majority of other screens (interfaces) used by the user) it will also be <intent-filter> <action> <Category> <type> <scheme> <authority> <path> <operator ER> An intentreceiver that allows the application to receive a Data Change and notification of a behavior, even this application is not running. like the activity tag, you can choose to include one or more <intent-filter> elements <service> services is a component that can be run at any time in the background. like Activity tags, you can choose to include one or more <intent-filter> elements <provider> contentprovider components to manage data persistence and data publishing, released data can be accessed by other applications.