打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
android如何添加桌面图标和卸载程序后自动删除图标

标签:

android如何添加桌面图标和卸载程序后自动删除桌面图标,这是一个应用的安装与卸载过程对桌面图标的操作,下面与大家分享下具体是如何实现的,感兴趣的朋友可以参考下哈

1:创建图标如下 

Intent intent = new Intent(); intent.setClass(this, SplashActivity.class); Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT); Parcelable icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon); addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name)); addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); addShortcut.putExtra("duplicate", 0); addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon); sendBroadcast(addShortcut); 

2:删除图标如下 

Intent intent = new Intent(); intent.setClass(this, SplashActivity.class); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT); Parcelable icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon); addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name)); addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); addShortcut.putExtra("duplicate", 0); addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon); sendBroadcast(addShortcut); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); 

需要两个过滤属性

android如何添加桌面图标和卸载程序后自动删除图标

标签:

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Android之生成桌面快捷方式(二)
html5添加到安卓桌面图标,Android向桌面添加快捷方式,使其指向特定的网页
Android中快捷方式的创建和删除(ShortCut)
Android应用启动后自动创建桌面快捷方式
Android生成快捷方式
[Android]为指定的应用创建桌面快捷方式
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服