8

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
    }
}
Athira
  • 1,177
  • 3
  • 13
  • 35

7 Answers7

2

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).

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
0

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)

snachmsm
  • 17,866
  • 3
  • 32
  • 74
0

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.

Gary Wang
  • 340
  • 4
  • 13
-1

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.

-2

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);
Vasudev Vyas
  • 726
  • 1
  • 10
  • 28
  • another solution follow this link : https://stackoverflow.com/questions/51061462/disabling-oreo-notification-dot – Vasudev Vyas Mar 30 '19 at 09:35
  • 1
    This is notification badge, can't you see the image in my question? – Athira Mar 30 '19 at 10:32
  • your question is "How to remove the badge in-app shortcut icon?". I can see the question. however, you are not placing your code over here how can we give the right answer. don't be over smart. – Vasudev Vyas Mar 30 '19 at 10:46
  • Read question description also – Athira Mar 30 '19 at 10:54
  • 2
    While this code may resolve the OP's issue, it is best to include an explanation as to how your code addresses the OP's issue. In this way, future visitors can learn from your post, and apply it to their own code. SO is not a coding service, but a resource for knowledge. Also, high quality, complete answers are more likely to be upvoted. These features, along with the requirement that all posts are self-contained, are some of the strengths of SO as a platform, that differentiates it from forums. You can edit to add additional info &/or to supplement your explanations with source documentation. – ysf Jun 28 '20 at 15:04
-2

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);


    }
Kintan Patel
  • 1,230
  • 8
  • 15
  • This does not work since OREO. INSTALL_SHORTCUT does not work. https://developer.android.com/about/versions/oreo/android-8.0-changes#as – dcanh121 Apr 03 '19 at 15:46
-2
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);
    }
}