问题描述
我正在创建一个用于创建图标的应用程序,例如 Ume Icon Changer,现在我正在使用此代码创建一个图标
public static void createShortCut3(Context context,Drawable drawable,String shortcutname,String packagename){
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packagename);
BitmapDrawable bd = (BitmapDrawable) drawable;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
ShortcutManager shortcutManager =
context.getSystemService(ShortcutManager.class);
if (shortcutManager.isRequestPinShortcutSupported()) {
ShortcutInfo pinShortcutInfo =
new ShortcutInfo.Builder(context,"app-shortcut")
.setIntent(intent)
.setShortLabel(shortcutname)
.setIcon(Icon.createWithAdaptiveBitmap(bd.getBitmap()))
.build();
Intent pinnedShortcutCallbackIntent =
null;
pinnedShortcutCallbackIntent = shortcutManager.createShortcutResultIntent(pinShortcutInfo);
PendingIntent successCallback = PendingIntent.getbroadcast(context,pinnedShortcutCallbackIntent,PendingIntent.FLAG_UPDATE_CURRENT);
shortcutManager.requestPinShortcut(pinShortcutInfo,successCallback.getIntentSender());
}
}
}
但我所有的图标都是用这个徽章创建的。
据我所知,您不能将其删除。但在 ume icon changer 和其他应用程序中,这是以某种方式完成的through the widget。
如何实现类似的功能?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)