广告
返回顶部
首页 > 资讯 > 移动开发 >android如何添加桌面图标和卸载程序后自动删除图标
  • 496
分享到

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

自动程序卸载Android 2022-06-06 10:06:13 496人浏览 安东尼
摘要

1:创建图标如下 代码如下: Intent intent = new Intent(); intent.setClass(this, SplashActivity.class

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安装后在桌面上不显示应用图标的解决方法Android 桌面图标右上角显示未读消息数字Android如何动态改变App桌面图标Android应用第一次安装成功点击“打开”后Home键切出应用后再点击桌面图标返回导致应用重启问题的解决方法Android实现系统的桌面图标文字的双行显示效果


--结束END--

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

本文链接: https://www.lsjlt.com/news/27625.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作