Androidmanifest. XML is a required file in every android program. It is located in the root directory of the project and describes global data in the package, including components exposed in the package (activities, services, and so on), their respective implementation classes, various data and startup locations that can be processed.
An important part of this file is its intent-filters. These filters describe the start position and time of the activity. Every time an activity (or operating system) needs to perform an operation, such as opening a webpage or contact book, it creates an intent object, this object carries some information that describes what you want to do, what data you want to process, the data type, and some other information. Android compares the intent object with the information in the intent-filter exposed by each application to find the most suitable activity to process the data and operations specified by the caller.
In the androidmanifest. xml file, in addition to declaring activities, content providers, services, and intent receivers in your program, you can also specify permissions and instrumentation (Security Control and testing ). This is a simple androidmanifest. xml.
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.my_domain.app.helloactivity"> <application android:label="@string/app_name"> <activity class=".HelloActivity"> <intent-filter> <action android:value="android.intent.action.MAIN"/> <category android:value="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application></manifest>
It is worth mentioning that almost all androidmanifest. xml contains namespace declarations in the first element, xmlns: Android = "http://schemas.android.com/apk/res/android ". In this way, various standard attributes in android can be used in files. It provides data in most elements.
Most manifests contain a single <Application> element, which defines all application-level components and attributes and can be used in a package. Any package that is considered as a top-level application and can be used by the program initiator must contain at least one activity component to support the main operation and launcher type, as shown in the above Code.
Here is a detailed list of androidmanifest. xml file structures, describing all the tags that can be used.
Manifest: root node, which describes all contents in the package. Under it, you can place:
Uses-SDK: required to compile the SDK. For example: <uses-SDK
Android: minsdkversion = "15"
Android: targetsdkversion = "16"/>
The former is the minimum SDK version requirement, and the latter is the target compilation version requirement. It must be consistent with the target API level in project. properties. Otherwise, the application will not run on the corresponding OS version.
Uses-permission: Requests Security licenses required for normal operation of your package. A manifest can contain zero or more elements. Example: If the self-compiled Camera app prompts fail at runtime, add the following statement to the XML file to check whether the problem can be solved.
<uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.FLASHLIGHT" />
Instrumentation: Declares the code used to test this package or other package command components. A manifest can contain zero or more elements.
Application: contains the root node declared by the application-level component in the package. This element can also contain global and default attributes in the application, such as tags, icons, topics, necessary permissions, and so on. A manifest can contain zero or one such element (no additional one is allowed ). Under it, zero or more of the following component declarations can be placed:
Activity is the main tool used to interact with users. When you open an application, the initial page is an activity. Most of the other pages used are implemented by different activities and declared in another activity tag. Note: Each activity must have a <activity> tag, whether used externally or only in its own package. If an activity has no corresponding tag, you cannot run it. In addition, to support running search for your activity, you can include one or more <intent-filter> elements to describe the operations supported by your activity:
Intent-filter: Declares the intent values supported by a specified group of parts to form an intentfilter. In addition to specifying different types of values under this element, attributes can also be placed here to describe the unique tag, icon and other information required for an operation. Intent action supported by the action component. Intent category supported by the category component.
Receiver: intentreceiver allows the application to obtain data changes or operations, even if it is not currently running. With activity tags, You can selectively include the <intent-filter> elements supported by one or more referers;
Service: A service is a component that can run at any time in the background;
Provider: contentprovider is a component used to manage persistent data and publish it to other applications.
Http://www.cnblogs.com/jocc/archive/2007/11/25/971511.html ()
Http://stackoverflow.com/questions/9718526/i-am-getting-java-lang-runtimeexception-fail-to-connect-to-camera-service-in-an ()