2

In the manifest, it is possible to specify multiple activities:

<activity
   android:name=".Activity0"
   android:label="@string/app_name0">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name=".Activity1"
    android:label="@string/app_name1">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

These will then result in two icons, placed on the launcher. I was wondering if the application can register more icons programmatically (based on application settings / user interaction with the app). Note that they would not need to run different activities, a single activity, starting with different intents would also work. Is this possible, or does one have to use widgets?

Cœur
  • 37,241
  • 25
  • 195
  • 267
the swine
  • 10,713
  • 7
  • 58
  • 100

1 Answers1

0

no need to use widgets - you can just add dummy activities that start your needed activity with the right parameters and then finish - you can also exclude them from recents so the user does not see the activity at all. You can also install a shortcut by runtime - but then you need permission: INSTALL_SHORTCUT

ligi
  • 39,001
  • 44
  • 144
  • 244
  • I see. Doesn't that somehow limit the maximum number of shortcuts to the number of activities that are in the manifest? Also, do you have a link to some documentation / tutorial on how to do this? – the swine Sep 28 '14 at 17:13
  • 1
    I think this might be the answer http://stackoverflow.com/questions/6493518/create-a-shortcut-for-any-app-on-desktop. – the swine Sep 29 '14 at 09:47