Skip to content Skip to sidebar Skip to footer

Creating A Shortcut Of An Android Application On Home Screen

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

Solution 1:

as Answer by @Kailash :

You can use below code it worked for me:

IntentshortcutIntent=newIntent();
shortcutIntent.setClassName("WRITE YOUR PACKAGE NAME", "WRITE HERE YOUR CLASS NAME");

IntentaddIntent=newIntent();
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-permissionandroid:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

Hope it Helps.

Post a Comment for "Creating A Shortcut Of An Android Application On Home Screen"