Я программно, используя код Android Dev, добавляю значок на домашний экран Oreo, но каждый раз, когда я открываю приложение, он просит добавить еще один значок - PullRequest
0 голосов
/ 09 января 2020
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {

    Intent shortcutIntent = new Intent(getApplicationContext(), SplashScreen.class);
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    shortcutIntent.setAction(Intent.ACTION_MAIN);

    ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(getApplicationContext(), "shortcut")
            .setShortLabel(getResources().getString(R.string.app_name))
            .setIcon(IconCompat.createWithResource(getApplicationContext(), R.mipmap.apt_launcher))
            .setIntent(shortcutIntent)
            .build();
    ShortcutManagerCompat.requestPinShortcut(getApplicationContext(), shortcut, null);
}
...