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>

Override Inline Styles with CSS (!important)

Ideally you shouldn’t use inline styles, If you’re faced with a situation where they exist and you’d like to override the inline css with that from a stylesheet you can do so using !important.

CSS:

#example p {
    color: blue !important;
}

HTML:

<div id="example">
  <p style="color:green;">This paragraph has an inline style</p>
</div>

In the above example, the paragraph will have blue text and not green as in the inline style because of the !important declaration in the CSS.

Note: Internet Explorer 6 will apply whatever the last style declared is, and takes no notice of !important declarations.