In this demo, you’ll explore key aspects of the Android manifest file and learn how to configure various app settings. We’ll cover changing the launch activity, modifying the app icon, adding permissions, and setting the app name.
Changing the Launch Activity
First, let’s look at how to change which activity is launched when the app loads:
-
Open your
AndroidManifest.xmlfile. -
Locate the
<activity>tag with the<intent-filter>containing:<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> -
This
intent-filterdesignates the main launch activity.
To change the launch activity:
-
Create a new activity (e.g.,
AlternateReality.kt). -
In the manifest, move the
intent-filterfrom the current main activity to the new activity. -
Set
android:exported="true"for the new launch activity. -
Set
android:exported="false"for the previous launch activity.
For example:
<activity
android:name=".AlternateReality"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="false">
</activity>
Changing the App Icon
The app icon is specified in the manifest under the <application> tag:
<application
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
...>
To change the icon:
-
Right-click the
resfolder in your project. - Select New ▸ Image Asset.
- Choose Launcher Icons (Adaptive and Legacy).
- Select your desired foreground and background images.
- Configure options as needed and click Next, then Finish.
This process creates new mipmap resources and updates the necessary XML files.
Adding Permissions
Permissions are added to the manifest file using the <uses-permission> tag. For example:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Add these tags outside the <application> tag but within the <manifest> tag.
Note: Some permissions require runtime requests in addition to manifest declarations. Refer to Android documentation or resources like “Android App Distribution” for more details on handling permissions.
Setting the App Name
The app name is typically set in the strings.xml resource file and referenced in the manifest:
-
Open
res/values/strings.xml. -
Locate or add the
app_namestring:<string name="app_name">Your App Name</string> -
In the manifest, ensure the application name references this string:
<application android:label="@string/app_name" ...>
Changing the value in strings.xml will update your app’s name.
Conclusion
This demo covered key aspects of configuring your Android app through the manifest file. Remember to rebuild and run your app after making changes to see them take effect. For more advanced topics and best practices, refer to the official Android documentation and additional learning resources.