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

    需要两个过滤属性

  • 相关阅读:
    不同版本strtotime("2016-09-04")输出不同问题
    Jquery,YUI这个著名js库名称作用的理解
    函数和方法
    js的关联数组
    windows信息
    改centos7的网卡名
    GIT命令
    安装时遇到:正在尝试其它镜像。 http://mirrors.btte.net/centos/7.2.1511/extras/x86_64/repodata/repomd.xml: [Errno 14] curl#6
    本地怎样访问虚拟机上的服务器
    yolo
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/5204555.html
Copyright © 2011-2022 走看看