1

Possible Duplicate:
Android create shortcuts on the home screen

I want to create a shortcut of my android application on home screen as soon as my application is installed in an android device. How do I do this..?

Community
  • 1
  • 1
adi
  • 698
  • 8
  • 15
  • @Ram,I want to create a shortcut as soon as application installs on device.I want create it before opening my application for the first time. I don't want to create it on a button click. – adi Oct 31 '12 at 05:32

1 Answers1

3

as Answer by @Kailash :

You can use below code it worked for me:

Intent shortcutIntent = new Intent();
shortcutIntent.setClassName("WRITE YOUR PACKAGE NAME", "WRITE HERE YOUR CLASS NAME");

Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "WRITE HERE YOUR SHORTCUT NAME");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(context, R.drawable.icon));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
            context.sendBroadcast(addIntent);

You have to use following permission in your AndroidManaifest.xml

<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

Hope it Helps.

Bhavesh Patadiya
  • 25,740
  • 15
  • 81
  • 107