Is it possible to have multiple app icons which start the same Activity with different intent extras ?
On latest Android versions - If there are more than one launcher activities and if we don't put this category tag then the activity which is mentioned first in the Android manifest file will get launched as start-up activity.
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.
It means you didn't specify an Activity for Android to launch as the default when the app opens from the launcher. You have to add an Intent Filter in the Manifest for the Activity you would like to act as the default when the app is being launched.
description: An alias for an activity, named by the targetActivity attribute. The target must be in the same application as the alias and it must be declared before the alias in the manifest. The alias presents the target activity as an independent entity.
There is no way to provide intent extras when launching the activity (via the Launcher).
However, what you can do is use <activity-alias>
tags that define additional app icons that will launch the same (target) activity.
EDIT: Add example:
This example shows a real activity call MyRealActivity
and an alias called Blahblah
. Both have intent-filters that will make them appear on the list of available apps. They have different labels and different icons so that they will look like 2 different apps to the user. However, they both launch the same activity. Please note that there is no java class for .Blahblah
, that is just a placeholder and must be unique.
<activity
android:name=".MyRealActivity"
android:label="@string/header_application"
android:icon="@drawable/icon_myapp">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity-alias
android:targetActivity=".MyRealActivity"
android:name=".Blahblah"
android:label="@string/header_blahblah"
android:icon="@drawable/icon_blahblah">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With