Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have more than one launcher Activity?

Is it possible to have more than one application in one apk file? or is there a way to have different launcher icons for different activities inside one app? I want to separate my app into some different (but related) logical parts.

like image 542
Ali Behzadian Nejad Avatar asked Mar 17 '13 07:03

Ali Behzadian Nejad


1 Answers

Yes, just mark two or more of your <activity>s as LAUNCHER within your manifest. In addition you have to set the android:taskAffinity attribute on both of your Launcher-Activities which specify the exact package and Activity to be started.

<activity android:label="MyApp" android:name=".MyApp" android:taskAffinity="com.example.MainActivity">
        <intent-filter>
            <action android:name=".MyApp"/>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
</activity>


<activity android:label="Settings" android:name=".Settings" android:taskAffinity="com.example.SettingsActivity" >
    <intent-filter>
        <action android:name=".Settings"/>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>
like image 108
poitroae Avatar answered Oct 15 '22 09:10

poitroae