Install launcher icon in home screen once

后端 未结 3 715
情书的邮戳
情书的邮戳 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: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);
    

提交回复
热议问题