首页 > 移动平台 > 详细

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

时间:2016-02-21 11:21:48      阅读:283      评论:0      收藏:0      [点我收藏+]

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如何添加桌面图标和卸载程序后自动删除图标

原文:http://www.cnblogs.com/zhujiabin/p/5204555.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!