AndroidManifest.xml is a required file for every application. It sits in the root folder for an application, and describes global values for your package, including the application components (activities, services, etc) that the package exposes and the implementation classes for each component, what kind of data each can handle, and where they can be launched.
An important aspect of this file are the intent filters that it includes. These filters describe where and when that activity can be started. When an activity (or the operating system) wants to perform an action such as open a Web page or open a contact picker screen, it creates an Intent object. This object can hold several descriptors describing what you want to do, what data you want to do it to, the type of data, and other bits of information. Android compares the information in an Intent object with the intent filter exposed by every application and finds the activity most appropriate to handle the data or action specified by the caller. More details on intents is given in the Intent reference page.
Besides declaring your application's Activities, Content Providers, Services, and Intent Receivers, you can also specify permissions and instrumentation (security control and testing) in AndroidManifest.xml. For a reference of the tags and their attributes, please see AndroidManifest.
A simple AndroidManifest.xml looks like this:
<?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 android:name=".HelloActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest>
Some general items to note:
Almost every AndroidManifest.xml (as well as many other Android
XML files) will include the namespace declaration
xmlns:android="http://schemas.android.com/apk/res/android"
in
its first element. This makes a variety of standard Android attributes
available in the file, which will be used to supply most of the data for
elements in that file.
Most manifests include a single <application>
element, which defines all of the application-level components and
properties that are available in the package.
Any package that will be presented to the user as a top-level application available from the program launcher will need to include at least one Activity component that supports the MAIN action and LAUNCHER category as shown here.
Here is a detailed outline of the structure of an AndroidManifest.xml file, describing all tags that are available.
Note: Every Activity must have an <activity> tag in the manifest whether it is exposed to the world or intended for use only within its own package. If an Activity has no matching tag in the manifest, you won't be able to launch it.
Optionally, to support late runtime lookup of your activity, you can include one or more <intent-filter> elements to describe the actions the activity supports.
You can also optionally associate one or more pieces of meta-data with your activity that other clients can retrieve to find additional arbitrary information about it:
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:48 |