2

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.

Talha
  • 699
  • 2
  • 12
  • 33
  • You may want to have a look at this post: http://stackoverflow.com/questions/6988511/how-to-add-apps-shortcut-to-the-home-screen – Amrit Jun 14 '13 at 06:50

1 Answers1

2

In Google play you can set this option to create home shortcut after installation.