AndroidManifest.xml File
AndroidManifest.xml File
In Android development, an Activity represents a single screen with a user interface, like a window or page in a desktop app or website. When you open an app, you are interacting with activities. The Android system manages the lifecycle of each activity by moving it through different stages as the user interacts with it or as system events occur (like incoming calls). Understanding the activity lifecycle is crucial to build smooth, efficient, and bug-free apps.
The AndroidManifest.xml file is a critical part of every Android application. It provides essential information about the app to the Android system before any of the app’s code is run. It lists the app’s components (activities, services, broadcast receivers, and content providers), required permissions, hardware and software features used, and other metadata.
Use of AndroidManifest.xml File
The AndroidManifest.xml file plays a key role in defining and configuring an Android app. It does the following:
- Declares application components: The file describes the components of the android application. It defines all the app’s activities, services, broadcast receivers, and content providers.
- Grants permissions: It requests the necessary permissions that the app needs to access device features like the internet, camera, or storage.
- Specifies minimum API Level: It declares the minimum version of Android required to run the app.
- Defines hardware and software features: It indicates if the app uses specific hardware features like Bluetooth, camera, GPS, etc.
- Sets app metadata: It provides additional info such as themes, icons, and app names.
Sample AndroidManifest.xml File
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myfirstapp"> <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" /> <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/Theme.MyFirstApp"> <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>