I am using following code to add shortcut at home screen
private void createShortcut() {
String appName = getString(R.string.app_name);
// Adding shortcut for MainActivity
// on Home screen
Intent shortcutIntent = new Intent(getApplicationContext(),
SplashActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
shortcutIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY );
//shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appName);
addIntent.putExtra("duplicate", false);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(
getApplicationContext(), R.drawable.ic_launcher));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);
}
and its manifest permission
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
crateShortcut() code is in my main activity class. When I launch the app shortcut successfully creates at home screen. I want when some one install my app through .apk it automatically create shortcut (without launching the app) on home screen. How I can do this? Is there any broadcast which tells that app installed?? Thanks in advance.