Android : Application Manifest Overview for beginners

What is AndroidManifest.xml file in Android?
- The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.
- It is responsible to protect the application to access any protected parts by providing the permissions.

- This file contains the information regarding your app level packages and different components activities, services, content providers, etc.
sample example of AndroidManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" > <application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" > <activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
</activity>
</application>
</manifest>
- Now let’s go through the element of AndroidManifest.xml :
(a.) <manifest> : manifest is the root element of the AndroidManifest.xml file.It must contain an <application>
element and specify xmlns:android
and package
attributes.
- Attributes :
xmlns:android , package , android:sharedUserId , android:targetSandboxVersion , android:sharedUserLabel, android:versionCode , android:versionName , android:installLocation
(b.) <application> : This element contains several subelements that declares the application component such as activity etc.It is declaration of the application.
- Many of these attributes (such as
icon
,label
,permission
,process
, andallowTaskReparenting
) set default values for corresponding attributes of the component elements.
(c.) <activity> : This is the subelement of application and represents an activity that must be defined in the AndroidManifest.xml file. It has many attributes such as label, name, theme, launchMode etc.
- This element can contains :
<intent-filter>
, <meta-data>
, <layout>
(d.) <intent-filter> : intent-filter is the sub-element of activity that describes the type of intent to which activity, service or broadcast receiver can respond to.
- This element can contains :
<category>
, <data>
(e.) <action> : It adds an action for the intent-filter. The intent-filter must have at least one action element.
- If there are no
<action>
elements in an intent filter, the filter doesn't accept anyIntent
objects. - Attribute :
android:name
(f.) <category> : It adds a category name to an intent-filter
Syntax:
<category android:name="string" />
These are few reference links for understanding attributes deeply :
- https://developer.android.com/guide/topics/manifest/action-element
- https://developer.android.com/guide/topics/manifest/activity-element
Happy Reading :)