Android Manifest File

In Android, each application consists of Android Manifest File, the mind, which is placed In the root directory of the project hierarchy. It is the most important file in the android application which provides an important piece of information to the Android system in order to run the application. So what does manifest file do? Let’s understand it.

  • Every application in android declares their components in the manifest file.
  • It is a structured XML file and it has the same name for all applications.
  • It is also used to name any third party library the application needs to be linked against and identifying any permissions the application expects to be granted.

[cce lang=”xml”]<?xml version=”1.0″ encoding=”utf-8″?>

<manifest>

<application>

<activity android:name=”com.sample.project.TestActivity

android:icon=”@drawable/test_pic.png”

android:label=”@string/test_label/>

</application>

</manifest>[/cce]

Let’s understand the attributes associated with the <activity> element

  • The name attribute of the <activity> element names the Activity subclass that implement the activity. The icon and the label attributes point to the resource files containing an icon and label that can be displayed to users to represent the activity.
  • If you try to start an activity that is not defined in the manifest file with the <activity> element you get a runtime exception. Each <activity> element supports (optional) intent-filter child tag which specify which intent launch the activity
  • The <application> element acts a container for <activity>, <service>, <provider>&<receiver> elements as well.
  • <service> element is defined for services, for each service used inside the application one must define the separate <service> element. Service element also supports intent-filter child tags to allow late runtime binding
  • <provider> element is defined for application Content Providers. Content Providers are used for managing database access and sharing the data within and between the different application.
  • <receiver> element is defined for broadcast receivers .When they are defined in the manifest they become more like global event listeners and listen to all the events of their matching type from the different application as well. They can also be created dynamically in the code.

There are many more elements which are defined under the manifest element tag which is used very commonly in the development such as :

  • Uses-permission
    • This is a part of the security model. It declares permissions you have determined that your application needs to operate properly. The permission you include will always be presented to the user to either grant or deny during installation. There are many android services that have cost or security implications. Example location services, SMS etc.
  • Permission
    • You need to define a permission in the android application manifest file before restricting access to an application component. You should use this tag to create permission definitions. With this tag you can specify the level of access the permission will permit (normal, dangerous, signature etc.), a label and an external resource containing the description that explains risk of granting this permission. Other apps which want to use the protected component need to include a uses-permission tag in their manifest file and have it granted before using it.

2 thoughts on “Android Manifest File”

Leave a Reply

Your email address will not be published. Required fields are marked *