What is correct method to create two launcher icons for towo activities? I tried it like this:
<activity
android:name=".SettingsActivity"
android:exported="true"
android:launchMode="singleTop"
android:label="@string/app_name">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity
android:name=".PreviewActivity"
android:exported="true"
android:launchMode="singleTop"
android:label="Preview">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
But the second activity runs only if there is not launched first one. If first one is launched and I tap on PreviewActivity icon it show SettingsActivity not PreviewActivity as it should. I tried many things like set priority, different order, launchmode and so..
How to do it?
Obviously, none of these two activities has an icon …
android:icon="@mipmap/launcher_01"
android:icon="@mipmap/launcher_02"
When using android:launchMode=”singleTop”
, the second click won’t start another activity, but will ultimately end up in method onNewIntent()
. When launching the activity from code, there’s also Intent
flags which one can pass, in order to change the behavior; most also exist in XML.
The problem may be android:taskAffinity
, because unless specifying two different affinity names, it is being assumed that all activities belong to the same affinity …