By Barry Burd

Every Android app has an AndroidManifest.xml file. The AndroidManifest.xml file provides information that a device needs in order to run the app. The AndroidManifest.xml file in this listing stores some options that you choose when you create a brand-new Android project. For example, the listing contains the package name, the minimum required SDK (the android:minSdkVersion attribute), and the target SDK (the android:targetSdkVersion attribute).

<?xml version="1.0" encoding="utf-8"?>
  android:versionName="1.0" >
    android:targetSdkVersion="16" />
    android:theme="@style/AppTheme" >
      android:label="@string/app_name" >
        <action android:name=
          "android.intent.action.MAIN" />
        <category android:name=
          "android.intent.category.LAUNCHER" />

For my money, the most important items in an AndroidManifest.xml file are the activity elements. The code in this listing has only one activity element. But a single Android app can have many activities, and each activity must have its own activity element in the app’s AndroidManifest.xml file.

An Android activity is one “screenful” of components. If you add an activity’s Java code to an Android application, you must also add an activity element to the application’s AndroidManifest.xml file. If you forget to add an activity element, you see an ActivityNotFoundException when you try to run the application.

Within an activity element, an intent-filter element describes the kinds of duties that this activity can fulfill for apps on the same device. To give you an idea, the action android.intent.action.MAIN indicates that this activity’s code can be the starting point of an app’s execution. And the category android.intent.category.LAUNCHER indicates that this activity’s icon can appear on the device’s Apps screen.