Configuring the Android Manifest File Android

The Android application manifest file is a specially formatted XML file that must accompany each Android application. This file contains important information about the application’s identity. Here you define the application’s name and version information and what applica- tion components the application relies upon, what permissions the application requir- es to run, and other application configuration information.

The Android manifest file is named AndroidManifest.xml and must be included at the top level of any Android project. The information in this file is used by the Android system to

  • Install and upgrade the application package.
  • Display the application details such as the application name, description, and icon to users.
  • Specify application system requirements, including which Android SDKs are support- ed, what hardware configurations are required (for example, d-pad navigation), and which platform features the application relies upon (for example, uses multitouch capabilities).
  • Launch application activities.
  • Manage application permissions.
  • Configure other advanced application configuration details, including acting as a service, broadcast receiver, or content provider.
  • Enable application settings such as debugging and configuring instrumentation for application testing.

Editing the Android Manifest File

The manifest resides at the top level of your Android project. You can edit the Android manifest file using the Eclipse Manifest File resource editor (a feature of the Android ADT plug-in for Eclipse) or by manually editing the XML.

Editing the Manifest File Using Eclipse

You can use the Eclipse Manifest File resource editor to edit the project manifest file. The Eclipse Manifest File resource editor organizes the manifest information into categories:

  • The Manifest tab
  • The Application tab
  • The Permissions tab
  • The Instrumentation tab
  • The AndroidManifest.xml tab

Let’s take a closer look at a sample Android manifest file. The figures and samples come from the Android application called Multimedia, which you build in Chapter “Using Android Multimedia APIs.”We chose this project because it illustrates a number of different characteristics of the Android manifest file, as opposed to the very simple default manifest file you configured for the My First Android App project.

Configuring Package-Wide Settings Using the Manifest Tab

The Manifest tab contains package-wide settings, including the package name, version information, and supported Android SDK information. You can also set any hardware or feature requirements here.

The Manifest tab of the Eclipse Manifest File resourceeditor.

The Manifest tab of the Eclipse Manifest File resourceeditor

Managing Application and Activity Settings Using the Application Tab

The Application tab contains application-wide settings, including the application label and icon, as well as information about the application components such as activities, intent filters, and other application components, including configuration for services, intent filters, and content providers.

Enforcing Application Permissions Using the Permissions Tab

The Permissions tab contains any permission rules required by your application. This tab can also be used to enforce custom permissions created for the application.

Managing Test Instrumentation Using the Instrumentation Tab

The Instrumentation tab allows the developer to declare any instrumentation classes for monitoring the application. We talk more about instrumentation and testing in Chapter “Testing Android Applications.”

The Application tab of the Eclipse Manifest File resource editor.

The Application tab of the Eclipse Manifest File resource editor

The Permissions tab of the Eclipse Manifest File resource editor.

The Permissions tab of the Eclipse Manifest File resource editor

Editing the Manifest File Manually

The Android manifest file is a specially formatted XML file. You can edit the XML manually by clicking on the AndroidManifest.xml tab.

Android manifest files generally include a single <manifest> tag with a single <application> tag. The following is a sample AndroidManifest.xml file for anapplication called Multimedia:

Here’s a summary of what this file tells us about the Multimedia application:

  • The application uses the package name com.androidbook.multimedia.
  • The application version name is 1.0.
  • The application version code is 1.
  • The application name and label are stored in the resource string called @string /app_name within the /res /values /strings.xml resource file.
  • The application is debuggable on an Android device.
  • The application icon is the graphic file called icon (could be a PNG, JPG, or GIF) stored within the /res/drawable directory (there are actually multiple versions for different pixel densities).
  • The application has five activities (MultimediaMenuActivity, AudioActivity, Still Image Activity, Video Play Activity, and Video RecordActivity).
  • MultimediaMenuActivity is the primary entry point for the application. This is the activity that starts when the application icon is pressed in the application drawer.
  • The application requires the following permissions to run: the ability to record audio, the ability to set the wallpaper on the device, the ability to access the built-in camera, and the ability to write settings.
  • The application works from any API level from 3 to 8; in other words, Android SDK 1.5 is the lowest supported, and the application was written to target Android 2.2.
  • Finally, the application requires a camera to work properly.

Now let’s talk about some of these important configurations in detail.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Android Topics