源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2021-11-06 09:33 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:android如何添加桌面图标和卸载程序后自动删除图标
[b]1:创建图标如下[/b]
[u]复制代码[/u] 代码如下:
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);
[b]2:删除图标如下[/b]
[u]复制代码[/u] 代码如下:
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");
需要两个过滤属性
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部