Overview of Android Manifest

Dinkar Kumar
3 min readAug 30, 2020

--

AndroidManifest.xml is the backbone of an android application. This file contains all the essential information required by an android build tool, from the name of the app to all the action this app can handle.

This is one of the most important files in the android application, this file preset at the project level.

The manifest file is expected to declare the following amongst several other things:

  • package of the app, which usually matches the namespace of your code. Android build tools use it to determine the location of code entities when building your project.
  • Components of the app, including all activities, services, broadcasters and content providers. Each component must define its basic properties, state capabilities, such as which device configurations it can handle, and intent filters that describe how the component can be started.
  • The permission that the app needs to access the secure sections of the system or other apps
  • The hardware and software feature that the app needs, affect which devices will be able to install the app from Google Play.

Let's first see the most important building block of the AndroidManinfest file.

  • <manifest>: This is the root element which has some important attributes like “package” and contains the next most important element of AndroidManifest <application> and some other useful elements like <uses-permission>.
  • <application>: This is the most important and must element of the manifest file, This element have some important attributes needed by the application like “icon”, “name”, “label”. This element contains subelements that declare each of the application’s components (like <activity>,<service>,<receiver>, etc) and has attributes that can affect all these components.

Features in File

Package name:

  • “package” is an attribute of <manifest> element which usually matches the namespace of your code, For example, the following snippet shows the root <manifest> element with the package name “com.dinkar.sample”:

App components

For all the subclass of the following components, we have to provide entry for them in manifest file else it cannot be started

  • Activity (<activity>)
  • Service (<service>)
  • BroadcastReceiver (<receiver>)
  • ContentProvider (<provider> )

Intent filters

The activities of the app, the services and the broadcast receivers are activated by intent.

Intent is a message defined by an Intent object that describes the action to be carried out, including the data to be used, the category of the component to perform the action, and other instructions.

When an app issues an Intent to the system, the system locates an app component in the manifest file of each app that can handle intent based on filter declarations of intent. The system launches the matching component instance and passes the Intent object to that component. If more than one app can handle the intent, the user can choose which app to use.

Permissions

Android apps must request permission to access sensitive information (like location) or some features of the system (like the camera).

Every permission is identified by a unique label.

For example, an app that needs to use the internet must have the following line in the manifest:

<uses-permission android:name=”android.permission.INTERNET” />

You can refer to the below link for the other permission constants.

https://developer.android.com/reference/android/Manifest.permission#constants

Starting with Android 6.0 (API level 23), some app permissions may be approved or rejected by the user at run time. But no matter which Android version your app supports, all requests for permission must be declared with an element of < uses-permission > in the manifest. If permission is granted, the protected features can be used by the App. If not, it will fail in its attempts to access those features.

Device compatibility

The manifest file is also where you can tell what kind of hardware or software features your app requires and what kind of device your app is compatible with. Google Play Store does not allow the installation of your app on devices that do not provide the features or system version required by your app.

The < use-function > element lets you declare the hardware and software features that your app needs, for example, if your app needs BLE hardware to work then you need to add the following line in your manifest file.

<uses-feature android:name=”android.hardware.bluetooth_le” android:required=”true” />

You can refer to the below links for Different device compatibility feature available to use.

Hardware: https://developer.android.com/guide/topics/manifest/uses-feature-element#hw-features

Software: https://developer.android.com/guide/topics/manifest/uses-feature-element#sw-features

Sample Manifest file

--

--

No responses yet