'How to remove the badge in app shortcut icon?

enter image description hereHow to remove the badge in app shortcut icon in android? When i create app shortcut programmatically, along with the icon specified for shortcut, app icon comes at the bottom-right corner of the icon. I don't want that badge.

Here is the code I used

    public static void addShortcutToHomeScreen(Context context)
{
    if (ShortcutManagerCompat.isRequestPinShortcutSupported(context))
    {
        ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(context, "#1")
                .setIntent(new Intent(context, Splash.class).setAction(Intent.ACTION_MAIN)) // !!! intent's action must be set on oreo
                .setShortLabel("Test")
                .setIcon(IconCompat.createWithResource(context, R.drawable.logo))
                .build();
        ShortcutManagerCompat.requestPinShortcut(context, shortcutInfo, null);
    }
    else
    {
        // Shortcut is not supported by your launcher
    }
}


Solution 1:[1]

No, there is no way. These additional options are added by launcher, not your app itself. Obviously, uninstall options will be not there if your app is not possible to be uninstalled (it's system app for example).

Solution 2:[2]

there is no such option for ShortcutInfo nor ShortcutManager. it depends on launcher and it should show this badge that user will know in which app it will open. without this icon there is no option to recognize which app added it (besides opening), thats not so user friendly... for example you could impersonate another app by adding e.g. FB icon and "Facebook" shortcut name, and Activity opened by this shortcut may be faked log-in screen. in short: this icon is/should be there for security reasons

in my launcher long press starts moving shortcut immediately (no dropdown menu as for launcher icon) and I don't have "App info" option on top of screen (in "moving mode"), only "Remove"

maybe consider adding an AppWidget stylized as launcher icon with app name? shortcuts are available since API25, widges are there from start, and since API26 you can requestPinAppWidget (similar dialog style as for adding shortcut)

Solution 3:[3]

Adding a shortcut (NOT app widget) via the Widgets screen (something like this video) could be a workaround. Create an activity that filter <action android:name="android.intent.action.CREATE_SHORTCUT" />, and create the shortcut in that activity by manually creating an Intent.EXTRA_SHORTCUT_INTENT intent (instead of via shortcutManager.createShortcutResultIntent()) and returning it with setResult().

See this answer for details. Please note that the actual behavior may still be different when using a different launcher (it may not work under some launcher). I only tested with Pixel Launcher and Microsoft Launcher under Android 11 and Android 12.

Solution 4:[4]

First download an icon pack from PlayStore (loads to choose from). Go back to the screen with the offending icon. Press and hold icon you want to change (i.e. the one with the extra Chrome logo) and press edit. Press change icon. It will give you option to choose from the icon pack so press that. You will then have a large choice of icons so choose the one which best represents the current icon or choose something wildly different. Then tap OK. It will change the icon and have no extra badge.

Solution 5:[5]

Try this may be work for you. mChannel.setShowBadge(false);

String id = "my_channel_01";
CharSequence name = getString(R.string.channel_name);
String description = getString(R.string.channel_description);
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel mChannel = new NotificationChannel(id, name, importance);
mChannel.setDescription(description);
mChannel.setShowBadge(false);

NotificationManager notificationManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(mChannel);

Solution 6:[6]

Add below line in your Manifest.xml

<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

Code for creating a shortcut on Desktop,

 private void addShortcut() {
        //Adding shortcut for MainActivity
        //on Home screen
        Intent shortcutIntent = new Intent(getApplicationContext(), BottomNavigationActivity.class);
        shortcutIntent.setAction(Intent.ACTION_MAIN);

        Intent addIntent = new Intent();
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "My Shortcut");
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
                Intent.ShortcutIconResource.fromContext(getApplicationContext(),
                        R.drawable.alert_clock));
        addIntent.putExtra("duplicate", false);
        addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
        getApplicationContext().sendBroadcast(addIntent);


    }

Solution 7:[7]

private void createNotificationChannel() {
    // Create the NotificationChannel, but only on API 26+ because
    // the NotificationChannel class is new and not in the support library
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CharSequence name = getString(R.string.channel_name);
        String description = getString(R.string.channel_description);
        int importance = NotificationManager.IMPORTANCE_DEFAULT;
        NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
        channel.setDescription(description);
         channel.setShowBadge(false)

        NotificationManager notificationManager = getSystemService(NotificationManager.class);
        notificationManager.createNotificationChannel(channel);
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rabbid76
Solution 2
Solution 3
Solution 4 Someone
Solution 5 Vasudev Vyas
Solution 6 Kintan Patel
Solution 7 Umesh Maurya