tags:

views:

278

answers:

2

Hi,

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

+1  A: 

See Intent.ACTION_CREATE_SHORTCUT.

Isaac Waller
+4  A: 

This is actually covered in the API Samples (App/"Launcher Shortcuts"). Have a look at this page for more info. 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.

Rexxars
This pointed me in the right direction, but your link is broken. The current link is here: [LauncherShortcuts.java](http://d.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/LauncherShortcuts.html)
Jake Basile