分享

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

 WindySky 2016-03-01

标签:

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

标签:

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多