Is it possible to have multiple app icons which start the same Activity with different intent extras ?
-
1What do you mean by "multiple launchers"? – David Wasser Jun 28 '12 at 09:35
-
1I mean several icons in the app launcher – sdabet Jun 28 '12 at 12:07
-
this is indeed possible and the accepted answer is wrong – JacksOnF1re Oct 02 '15 at 17:50
-
@JacksOnF1re feel free to share your answer then – sdabet Oct 02 '15 at 18:05
-
Well, as I said it depends on how you define launcher and extras. You surely do not really need extras, do you? You want to store some additional information and that is possible, as david proved it himself. You can even add "real" extras in shortcuts, if they are good enough for you, as nepster stated out. And third and last, if you REALLY REALLY want extras provided for your targetActivity, then just start from an alias a second activity in forehand, without any layout, add the extras, and start your original activity afterwards. So, to say "it is not possible", may be right on a low level.. – JacksOnF1re Oct 02 '15 at 19:39
-
... but to achive the things you surely want, is not. – JacksOnF1re Oct 02 '15 at 19:40
2 Answers
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>

- 93,459
- 16
- 209
- 274
-
1
-
-
-
7FYI, and you can easily tell from the ActivityInfo retrieved via the PackageManager whether your app has been started from an alias or the original activity. I do this by looking at the activity label and start the main activity in different states depending on it. – sschuberth May 21 '13 at 11:14
-
1
-
If you use a manifest like the one above, will the user get two icons in their launcher when they install the app? If not, which one will it use? – waterlooalex Jul 09 '15 at 14:45
-
-
-
Just check this link with complete description http://easybook4u.com/index.php/2017/09/01/how-to-change-an-application-launcher-icon-and-title-programmatically-in-android/ – Himanshu arora Sep 01 '17 at 17:10
-
If I happen to set an attribute like `android:launchMode="singleTask"` and lets say the original activity has the same attribute defined like `android:launchMode="singleTop"` which one would take the precedence? – stdout Jun 08 '20 at 11:24
-
1@stdout The documentation https://developer.android.com/guide/topics/manifest/activity-alias-element clearly states which attributes can be set in `
`. `launchMode` isn't one of them. – David Wasser Jun 08 '20 at 11:40 -
@DavidWasser Thx. I only asked because I see it being used in the manifest file (of a recent project) and got a bit confused. – stdout Jun 08 '20 at 13:00
-
2@stdout It is ignored in the `
` tag, so the `launchMode` of the target (original) ` – David Wasser Jun 08 '20 at 13:02` is used.
I am not sure why you want it. But you can create shortcut on homeScreen which opens the sameApp with different extras.
Have a look at this answer. and this

- 1
- 1

- 33,936
- 20
- 234
- 300