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 an 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
  1. <manifest xmlns:android=http://schemas.android.com/apk/res/android  
  2. package="string"  
  3. android:shareduserId="string"  
  4. android:sharedUseLabel="string resource"  
  5. android:versionCode="integer"  
  6. android:versionName="string"  
  7. 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
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     package="com.urlconnect"  
  4.     android:versionCode="1"  
  5.     android:versionName="1.0" > 
  1. <uses-permission android:name="android.permission.INTERNET" />  
  2.     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />   
  3.    
  4.     <uses-sdk  
  5.         android:minSdkVersion="7"  
  6.         android:targetSdkVersion="16" />  
  7.    
  8.     <application  
  9.         android:allowBackup="true"  
  10.         android:icon="@drawable/ic_launcher"  
  11.         android:label="@string/app_name"  
  12.         android:theme="@style/AppTheme" >  
  13.         <activity  
  14.             android:name="com.urlconnect.MainActivity"  
  15.             android:label="@string/app_name" >  
  16.             <intent-filter>  
  17.                 <action android:name="android.intent.action.MAIN" />  
  18.    
  19.                 <category android:name="android.intent.category.LAUNCHER" />  
  20.             </intent-filter>  
  21.    
  22.          </activity>  
  23.    
  24.     </application>  
  25.    
  26. </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
  1. <manifest>  
  2.        <application>  
  3.            <service  android:name="com.example.project.secretServices"  
  4.            </service>  
  5.        </application>  
  6. </manifest>