BCA / B.Tech 9 min read

What is AndroidManifest.xml in English

What is AndroidManifest.xml in English


The `AndroidManifest.xml` file is a crucial component of every Android application. It acts as the blueprint or control file for the app, providing essential information to the Android build tools, the Android operating system, and the Google Play Store. Without this file, the Android system cannot correctly run the app.

Core Purpose of AndroidManifest.xml:

  • Declare App Components: It lists all the major building blocks of the app, such as Activities, Services, Broadcast Receivers, and Content Providers.
  • Define Permissions: It specifies the permissions the app needs to access protected parts of the system or other apps (e.g., internet access, camera, contacts).
  • Declare Hardware/Software Features: It declares what hardware (like a camera or GPS) or software features the app requires, which helps Google Play filter the app for devices that don’t support these features.
  • Set App Metadata: It contains metadata like the app's package name, version code, version name, icon, and label.

Key Elements of the Manifest File:

1. <manifest>
  • This is the root element of the file.
  • It must contain the `package` attribute, which serves as the unique identifier for your application.
2. <application>
  • This element declares the application itself. It contains attributes that apply to the whole app.
  • `android:icon`: The icon for the app.
  • `android:label`: The default title for the app.
  • `android:theme`: The theme applied to all activities.
3. <activity>
  • Declares an activity, which is a single screen with a user interface.
  • Every activity used in the app must be declared here.
  • The main activity, which is the entry point of the app, is marked with a special ``.
4. <service>
  • Declares a service, a component that can perform long-running operations in the background without a user interface.
5. <receiver>
  • Declares a broadcast receiver, a component that responds to system-wide broadcast announcements (e.g., when the device boots up or a message is received).
6. <provider>
  • Declares a content provider, which manages a shared set of app data.
7. <uses-permission>
  • Requests a permission that the app must be granted by the user in order to operate correctly.
  • Example: `` to access the internet.
8. <uses-feature>
  • Declares a single hardware or software feature that is used by the application.
  • Example: `` to state that the app requires a camera.
9. <intent-filter>
  • Specifies the types of intents that an activity, service, or broadcast receiver can respond to.
  • It is used to declare the main entry point of the application.

Example of a simple AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>