manifest

manifest

AndroidManifest.xml :-
In Android, the manifest folder doesn't exist by default. However, there is a crucial file called the AndroidManifest.xml that resides within the app/src/main directory of an Android project. This file is essential as it contains critical information about the Android app. Here's an explanation of its elements:

AndroidManifest.xml Elements:

  1. Package Name:
      • Defines the unique identifier for the app. It's specified within the <manifest> tag as package="com.example.myapp".
       
       
  1. Permissions:
      • Specifies permissions required by the app to access certain device functionalities, like camera, internet, etc. These are declared using <uses-permission> tags.
      • following page will tell more about permissions in android
Permission
Permission
 
  1. Application Components:
      • Activities: Represents the app's screens. Each <activity> tag defines a screen and its properties.
      • Services: Background processes that run independently of the UI.
      • Broadcast Receivers: Responds to system-wide broadcast announcements.
      • Content Providers: Manages a shared set of app data.
       
  1. Intent Filters:
      • Defined within <activity>, <service>, <receiver>, or <provider> tags, they specify the types of intents (e.g., actions, categories, data) that the component can respond to.
       
  1. Main Launcher Activity:
      • Specifies which <activity> should be launched when the app starts. It's defined using an <intent-filter> inside the <activity> tag with the android.intent.action.MAIN and android.intent.category.LAUNCHER actions.
       
  1. App Permissions and Features:
      • Defines which hardware/software features the app requires, such as camera, GPS, NFC, etc., using <uses-feature> tags.
       
  1. Versioning Information:
      • Specifies the android:versionCode and android:versionName to manage app versioning in the <manifest> tag.

Example:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="<http://schemas.android.com/apk/res/android>" package="com.example.myapp"> <!-- Permissions --> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <!-- Main Launcher Activity --> <activity android:name=".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> <!-- Other Activities, Services, Broadcast Receivers, Content Providers --> </application> <!-- Versioning Information --> <uses-sdk android:minSdkVersion="XX" android:targetSdkVersion="YY" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> </manifest>
This example illustrates some crucial elements within the AndroidManifest.xml file. Adjustments and additions are made as per the app's requirements, like adding more activities, services, permissions, etc. The manifest file essentially serves as a roadmap for Android, guiding how the system should interact with the app's components.