How To Have Multiple Launcher Icons In One Android APK Install For Different Activities

If you’ve ever installed Facebook from the Google Play store and noticed it adds 2 launcher icons (Facebook and Fb Chat) and wondered how they do this (have multiple launcher icons in one install bound to different activities) here is how to achieve this.

Step 1) For each activity you wish to expose an icon for in your Android app, add a corresponding “android:icon” attribute to your in AndroidManifest.xml:

android:icon="@drawable/power_saver_settings_app_icon"

Step 2) The key to getting this working is also adding an “android:taskAffinity” attribute with a unique value for each activity. Note that in the example below I just used the fully qualified package name + activity name. You can use any value you want here though:

android:taskAffinity="com.logicvoid.androidadvancedsettings.PowerSaverSettingsActivity"

Something to note is that the icon you define in the application section of AndroidManifest.xml (<application android:icon="@drawable/app_icon"..) will NOT be visible in the launcher, however it is still important to include as the Google Play store consumes this asset and will display it representing your application.

Complete AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.logicvoid.powersaversettings"
    android:versionCode="3"
    android:versionName="2.0" >

    <uses-sdk android:minSdkVersion="15" />
    

    <application
        android:icon="@drawable/app_icon"
        android:label="@string/app_name" >
        
        <activity            
            android:icon="@drawable/power_saver_settings_app_icon"
            android:name=".PowerSaverSettingsActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:label="@string/power_saver_settings_launcher_name" 
            android:taskAffinity="com.logicvoid.androidadvancedsettings.PowerSaverSettingsActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        
        <activity            
            android:icon="@drawable/roaming_guard_settings_app_icon"
            android:name=".RoamingGuardsSettingsActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:label="@string/roaming_guards_settings_launcher_name"
            android:taskAffinity="com.logicvoid.androidadvancedsettings.RoamingGuardsSettingsActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Advertisements

2 thoughts on “How To Have Multiple Launcher Icons In One Android APK Install For Different Activities

    • Hello sir,

      I have used taskAffinity in AndroidManifest.But I have checked that without using of taskAffinity we can also show icon for both the screen.I am so confusing why we are using taskAffinity in AndroidManifest.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s