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

    需要两个过滤属性

  • 相关阅读:
    vue 设置初始值 为null 进行文字长度判断
    js ajax传参 定义的参数和传的参数不一样
    js 删除字符串前几位字符,和删除最后一个字符
    js splice 删除数组 相邻的数据满足条件未被删掉
    js 将对象增加新键值对
    js 将数组添加key
    js 删除掉数组中的 ' '
    js 如何删除数组中指定对象及其值
    接口
    分支结构
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/5204555.html
Copyright © 2011-2022 走看看