博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android如何添加桌面图标和卸载程序后自动删除图标
阅读量:6932 次
发布时间:2019-06-27

本文共 1281 字,大约阅读时间需要 4 分钟。

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");

需要两个过滤属性

转载地址:http://kgpjl.baihongyu.com/

你可能感兴趣的文章
Manage Spring Boot Logs with Elasticsearch, Logstash and Kibana
查看>>
Linux curl使用简单介绍 (转)
查看>>
专业(技术和流程规范)(转)
查看>>
poj3070 (斐波那契,矩阵快速幂)
查看>>
POI2011 棒棒糖 Lollipop
查看>>
Apache -Common-lang包使用
查看>>
python随机数seed用法
查看>>
linux下搜索命令
查看>>
rimraf node_modules 快速删除
查看>>
chomre常用快捷键
查看>>
关于this绑定的四种方式
查看>>
【原创】一起学C++ 之指针的--/++ ---------C++ primer plus(第6版)
查看>>
CDC,CPaintDC,CClientDC,CWindowDC
查看>>
HDU5945 Fxx and game(DP+单调队列优化)
查看>>
ImageAnimator类方法(动画设计)
查看>>
django启动创建用户失败
查看>>
Moco 详解
查看>>
MySQL-事物、索引和视图
查看>>
卸载默认安装的OpenJDK,然后安装SUN公司的JKD(CentOS 7环境下)
查看>>
计算机视觉(1)图像预处理
查看>>