zoukankan      html  css  js  c++  java
  • android如何添加桌面图标和卸载程序后自动删除图标

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

    需要两个过滤属性

  • 相关阅读:
    hdu 2586(最近公共祖先LCA)
    hdu 3394(点双连通)
    hdu 4005(边双连通)
    hdu 2460(tarjan求边双连通分量+LCA)
    【转载】8天学通MongoDB——第四天 索引操作
    【转载】8天学通MongoDB——第三天 细说高级操作
    [转载]MongoDB开发学习 经典入门
    【原创】jQuery 仿百度输入标签插件
    ★《唐琅探案》后记【2】
    ★《唐琅探案》后记【1】
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/5204555.html
Copyright © 2011-2022 走看看