Install launcher icon in home screen once

后端 未结 3 716
情书的邮戳
情书的邮戳 2021-02-05 22:33

When a user installs an Android app, a launcher icon is created in the apps menu. Many users I talk to expect that when they install an app, an icon should appear automatically

相关标签:
3条回答
  • 2021-02-05 22:35

    In the example, it returns the intent in setResult(...). I believe you need to run sendBroadcast(intent) to trigger installation of the shortcut.

    0 讨论(0)
  • 2021-02-05 22:43

    The class DroidGap extends Activity so you can just add in the code from the link you provided to add a shortcut.

    0 讨论(0)
  • 2021-02-05 22:45
        Intent shortcutIntent = new Intent(getApplicationContext(), HomeScreen.class);      
        shortcutIntent.setAction(Intent.ACTION_MAIN);
    
        Intent addIntent = new Intent();
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "AIMS ICD");
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.aims));
        addIntent.putExtra("duplicate", false);
        addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
        getApplicationContext().sendBroadcast(addIntent);
    
    0 讨论(0)
提交回复
热议问题