Anatomy of an Android App

Sep 10 2024 · Kotlin 1.9.23, Android 14, Android Studio Iguana

Lesson 03: Explore the Android Manifest

Demo

Episode complete

Play next episode

Next
Transcript

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:

  1. Open your AndroidManifest.xml file.
  2. Locate the <activity> tag with the <intent-filter> containing:
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    
  3. This intent-filter designates the main launch activity.

To change the launch activity:

  1. Create a new activity (e.g., AlternateReality.kt).
  2. In the manifest, move the intent-filter from the current main activity to the new activity.
  3. Set android:exported="true" for the new launch activity.
  4. 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:

  1. Right-click the res folder in your project.
  2. Select New ▸ Image Asset.
  3. Choose Launcher Icons (Adaptive and Legacy).
  4. Select your desired foreground and background images.
  5. 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:

  1. Open res/values/strings.xml.
  2. Locate or add the app_name string:
    <string name="app_name">Your App Name</string>
    
  3. 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.

See forum comments
Cinema mode Download course materials from Github
Previous: The App Manifest Next: Conclusion