Learn About Android Manifest.Xml File

Android Manifest file

Every application in Android has an Android manifest file that is present in its root directory. It is a XML file that works as a bridge between developers and the Android system. The Android manifest XML file allows the developer to tell all the functionalities and requirements of the application. It contains the names of the Java package for the application. It describes the component of the application Activities, Services, Broadcast Reciever and the Content Provider that the application is composed of. In this the user can interact with the application by giving the required permission to the manifest XML file.

The Android Manifest.xml is generated as a part of the build process and XML found within the properties of the \Android Manifest.xml merged with the XML generated based on custom attributes. The merging Process is trivial. It uses the custom attributes within the code to generate XML elements.

Syntax

<manifest xmlns:android=http://schemas.android.com/apk/res/android
package="string"
android:shareduserId="string"
android:sharedUseLabel="string resource"
android:versionCode="integer"
android:versionName="string"
android:installation=["auto" "internally" "preferExternal" ]>

Elements of the Android manifest.xml file

These are the elements of the Android manifest.xml file that cannot be changed and you cannot add your elements to the Android Manifest file:

<action>

<application>

<activity-alias>

<application>

<category>

<data>

<grant-uri-permission>

<instrumentation>

<intent-filter>

<manifest>

<meta-data>

<permission>

<permission-group>

<permission-tree>

<provider>

<receiver>

<service>

<support-screens>

<uses-configuration>

<uses-features>

<uses-library>

<uses-permission>

<uses-sdk>
 

Elements of application component

These should be enclosed in the <application> container:

activity: has the set of attributes based on the user interface

activity-alias: specific target activities

service: has the operation provided by any library or API , running in the background that is not visible

receiver: enables the application to receive intents that are broadcast by the system or application

provider: provides some structure to access application data

This information is needed by the system to run any file of the application. That's why this file is created during installation, not during execution.

Structure of Android Manifest file

<manifest>

           <Elements>

                     <application>

           </Elements>

                     </application>

</manifest>


Simple Android manifest.xml file

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.urlconnect"

    android:versionCode="1"

    android:versionName="1.0" >

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

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 


    <
uses-sdk

        android:minSdkVersion="7"

        android:targetSdkVersion="16" />

 

    <application

        android:allowBackup="true"

        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name"

        android:theme="@style/AppTheme" >

        <activity

            android:name="com.urlconnect.MainActivity"

            android:label="@string/app_name" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

 

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

 

         </activity>

 

    </application>

 

</manifest>

 

Clipboard02.jpg

The Android Manifest file must be the file name and should be present in a root directory.
Elements inside this have no specific order.


How to declare the class in the Manifest file

<manifest>

       <application>

           <service  android:name="com.example.project.secretServices"

           </service>

       </application>

</manifest> 

Next Recommended Readings