【发布时间】:2021-05-13 20:55:19
【问题描述】:
8 android之后,我的应用程序图标出现在快捷方式上。
我知道这是专门添加的,用于通知用户哪个应用创建了快捷方式。
这是当前用于创建图标的代码。
ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE);
BitmapDrawable bd = (BitmapDrawable) ic;
if (shortcutManager.isRequestPinShortcutSupported()) {
Intent shortcutInfoIntent = new Intent(context, MainActivity.class);
shortcutInfoIntent.setAction(Intent.ACTION_VIEW);
shortcutInfoIntent.putExtra("pckg", pck);
ShortcutInfo info = new ShortcutInfo.Builder(context, "iconId")
.setIcon(Icon.createWithBitmap(bd.getBitmap()))
.setShortLabel(label)
.setIntent(shortcutInfoIntent)
.build();
PendingIntent shortcutCallbackIntent = PendingIntent.getBroadcast(context, 0, new Intent(context, MyReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
shortcutManager.requestPinShortcut(info, shortcutCallbackIntent.getIntentSender());
}
我知道这是一个相当流行的问题,但没有人提供正常的解决方案。 但我需要以某种方式把它拿走
我确信这是可能的,因为它是在 x icon changer 中实现的,其中创建的图标没有这些徽章。
请写下你所有的想法如何解决它
【问题讨论】:
标签: java android shortcut android-shortcut