You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android桌面应用图标出现多余迷你徽章,如何去除?

解决桌面快捷方式图标带迷你徽章的问题

核心原因

你创建的是固定快捷方式(Pinned Shortcut),而非系统自动生成的默认应用启动图标,大部分安卓启动器会给这类手动创建的快捷方式添加迷你徽章来区分。

具体修复方案

1. 优先依赖系统自动生成图标(推荐)

安卓应用安装后,启动器会自动在桌面添加默认图标,除非用户手动禁用了该功能。你可以直接移除整个手动创建快捷方式的逻辑,既避免徽章问题,也符合系统规范。

2. 若必须手动创建,调整代码匹配默认启动Intent

如果确实需要通过代码触发添加,要确保你的快捷方式Intent和Manifest中主Activity的配置完全一致:

针对API 26(Android 8.0)及以上版本

修改homeScreenShortCut的Intent配置,添加CATEGORY_LAUNCHER,同时简化ShortcutInfo的创建:

Intent homeScreenShortCut = new Intent(appContext, MainActivity.class);
// 匹配Manifest里的主Activity Intent Filter
homeScreenShortCut.setAction(Intent.ACTION_MAIN);
homeScreenShortCut.addCategory(Intent.CATEGORY_LAUNCHER);
homeScreenShortCut.setPackage(appContext.getPackageName());

ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
assert shortcutManager != null;
if (shortcutManager.isRequestPinShortcutSupported()) {
    ShortcutInfo pinShortcutInfo = new ShortcutInfo.Builder(this, "browser-shortcut")
            .setShortLabel(getString(R.string.app_name))
            .setLongLabel(getString(R.string.app_name))
            .setIcon(Icon.createWithResource(this, R.drawable.ic_launcher))
            .setIntent(homeScreenShortCut)
            .build();
    shortcutManager.requestPinShortcut(pinShortcutInfo, null);
}

这样创建的快捷方式会和系统默认图标保持一致,启动器不会添加迷你徽章。

针对API 26以下版本

同样修改Intent,添加CATEGORY_LAUNCHER,同时确保广播参数正确:

Intent homeScreenShortCut = new Intent(appContext, MainActivity.class);
homeScreenShortCut.setAction(Intent.ACTION_MAIN);
homeScreenShortCut.addCategory(Intent.CATEGORY_LAUNCHER);

// 卸载旧快捷方式的逻辑保持不变
if(shortcutReinstall) {
    // ... 原有卸载代码
}

Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, homeScreenShortCut);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher));
addIntent.putExtra("duplicate", false);
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);

关于自定义迷你徽章的补充(你提到的好奇点)

如果之后想设置不同的迷你徽章,只需要在API26+的ShortcutInfo.Builder中调用setIcon()时传入不同的图标资源即可,启动器会自动将这个图标作为迷你徽章显示。

内容的提问来源于stack exchange,提问作者MKE

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 16:18:35