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.
Asked
Active
Viewed 5,402 times
2 Answers
14
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>

poitroae
- 21,129
- 10
- 63
- 81
-
1How the OS will decide, which launcher activity to trigger? – Narendra Singh Dec 12 '16 at 15:01
-
3Doesn't work, both of them start the first declared Activity with action.MAIN – Haroun Hajem Aug 07 '18 at 14:28
-
What actually the `android:taskAffinity` do, because it works without it. – WerWet Dec 20 '21 at 00:35
-
it controls the flow between activities when the app pause/continue depending on how it was started – Luiz Felipe Mar 31 '22 at 13:36
0
Yes, You can have more than one launcher activity in your application. This will not create any kind of compile-time or run time error. You will find two launcher logos of your application in your device can launch different activities as we defined in manifest.

Nisargi Joshi
- 286
- 3
- 12