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", );
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", );
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
sendBroadcast(addShortcut);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");

需要两个过滤属性

最新文章

  1. eclipse直接访问数据库
  2. 【小贴士】关于transitionEnd/animate的一个有趣故事
  3. ORACLE应用调优:请避免SQL做大量循环逻辑处理
  4. arguments.callee 调用自身 caller,callee,apply and call
  5. 微信的 JSSDK
  6. System Center的一些资料收集
  7. Visual Studio 不生成.vshost.exe和.pdb文件的方法
  8. http://www.360doc.com/content/10/1012/09/3722251_60285817.shtml
  9. (原创)speex与wav格式音频文件的互相转换
  10. 11-05-sdust-个人赛赛后随想
  11. 剑指Kubernetes 揭秘腾讯云的PaaS技术选型策略
  12. springmvc组件--ViewResolver
  13. 【springBoot】之配置文件application
  14. spring boot 学习(四)Druid连接池的使用配置
  15. Cisco Packet Tracer中通过集线器组网
  16. mybatis学习------打包xml映射文件
  17. 前端工程精粹(一):静态资源版本更新与缓存(附精简js的工具)
  18. bzoj 1731: [Usaco2005 dec]Layout 排队布局 ——差分约束
  19. 基于BeanNameViewResolver解析器,自定义视图
  20. Django框架 之 Pagination分页实现

热门文章

  1. 自定义标签(TagSupport )
  2. type,isinstance判断一个变量的数据类型
  3. 关于CDC在非控件类中的使用
  4. Adobe Flash Player已经终止一项可能不安全的操作,解决方案
  5. android下文件下载
  6. android adb经常使用的命令
  7. T-SQL函数及用法--转
  8. C# inherit
  9. jQuery 1.9+ ajaxStart事件无效,无法被触发的原因。
  10. DevExpress ASP.NET 使用经验谈(8)-ASPxGridView自定义列和基本事件