3

I'm writing program for Android (SDK 1.5). I would like to know how to add/register one of my program activities in "Home Screen -> Menu -> Add-> Shortcuts" (or on Hero "Home Screen -> Menu -> Add to Home-> Shortcut") so that user will be able to add it to his home screen. Is there an Intent Filter or any other way to achieve that?

Thanks

2 Answers2

6

This is actually covered in the API Samples (App/"Launcher Shortcuts"). Also check out the ApiDemos manifest, which provides a pretty good explanation (look for the LauncherShortcuts part).

Basically, your provide an intent filter in your manifest containing

<action android:name="android.intent.action.CREATE_SHORTCUT" />

In the activity you defined as the receiver, you check if the calling intent is a ACTION_CREATE_SHORTCUT intent, and if so create a returning intent with some extras (check out the setupShortcut function in the link I provided). You could also check out the source code for Connectbot which does this pretty well. Hope that helps.

Juuso Ohtonen
  • 8,826
  • 9
  • 65
  • 98
Rexxars
  • 1,167
  • 8
  • 10
1

See Intent.ACTION_CREATE_SHORTCUT.

Isaac Waller
  • 32,709
  • 29
  • 96
  • 107