3.4 Manifest
Every Android app, large or small, has a very important little file in the root folder called AndroidManifest.xml
. This file describes crucial information about the app, including the application's name, the activities it holds, the permissions it requests, and the hardware and software requirements needed to run the app in the first place. Android Studio will handle the boilerplate code of the manifest when you first create the app, but often you will need to modify the file to suit your own needs.
The root element requires an attribute for your app's package name, which the build tools will use to resolve any relative classes in the package and generate the resources file.
In the child <application ...>
tag, these attributes specify project-specific information including where you set the app icon for your project.
Under the application tag is where most of the configuring will be done. For each activity that you create in your app, you must declare a corresponding XML activity element as a child of <application ...>
in AndroidManifest.xml
. Otherwise, that activity will never be seen by the system and can never be launched with an intent.
An example manifest looks something like:
We can add a child element of type intent-filter
to each Activity
element. This is where an activity specifies what implicit intents the application can receive. In the manifest file for Google’s Gmail app, one of the activities would have the action android.intent.action.SEND
under their intent filter, which allows the application to receive the implicit intent with action Intent.ACTION_SEND
.
The example below is of an activity that is recognized by the system as the entry point to this application (labeled with action.MAIN
), and as something that shows up and can be launched from the app drawer - the area in your phone where all installed apps are stored (labeled with category.LAUNCHER
).
The manifest file is a small but mighty beast that controls activities, permissions, and implicit intents. If this file becomes messed up, then some issues will likely manifest their way into your application. Heh 🤭
Last updated