如果你在APP里面是无法修改角标的,你要在桌面才能修改角标

解决办法是针对小米系统增加延时的操作显示

//延迟操作

new Handler().postDelayed(new ShortCutRunnable(count,notification,notifId,notificationManager),600);

/**

*作者:GaoXiaoXiong

*创建时间:2018/4/8

*注释描述:延迟显示角标个数,解决小米不正确显示角标

*/

class ShortCutRunnable implements Runnable{

private int count;//要显示的个数

private int notifId;//可以采用System.currentTimeMillis()

private Notification notification;

private NotificationManager notificationManager;

public ShortCutRunnable(int count, Notification notification,int notifId,NotificationManager notificationManager) {

this.count = count;

this.notification = notification;

this.notifId = notifId;

this.notificationManager = notificationManager;

}

@Override

public void run() {

try {

ShortCutBadgerCount.getShortCutBadgerCount().clearCount();//我自己定义的

Field field = notification.getClass().getDeclaredField("extraNotification");

Object extraNotification = field.get(notification);

Method method = extraNotification.getClass().getDeclaredMethod("setMessageCount", int.class);

method.invoke(extraNotification, count);//显示个数

} catch (Exception e) {

BAFLogger.e(TAG,e.getMessage());

}

notificationManager.notify(notifId, notification);//显示通知

}

}

ShortCutBadgerCount.java

/**

* 创建时间: 2018/4/4

* gxx

* 注释描述:角标个数

*/

public class ShortCutBadgerCount {

private ShortCutBadgerCount() {

}

private int cutCount=0;

private volatile static ShortCutBadgerCount shortCutBadgerCount;

public static ShortCutBadgerCount getShortCutBadgerCount(){

if (shortCutBadgerCount==null){

synchronized (ShortCutBadgerCount.class){

if (shortCutBadgerCount==null){

shortCutBadgerCount = new ShortCutBadgerCount();

}

}

}

return shortCutBadgerCount;

}

/**

*作者:GaoXiaoXiong

*创建时间:2018/4/4

*注释描述:添加1个角标

*/

public int addCount(){

this.cutCount+=1;

setCutCount(this.cutCount);

return cutCount;

}

/**

*作者:GaoXiaoXiong

*创建时间:2018/4/4

*注释描述:设置个数

*/

public void setCutCount(int cutCount) {

this.cutCount = cutCount;

}

/**

*作者:GaoXiaoXiong

*创建时间:2018/4/8

*注释描述:消息个数

*/

public int getCutCount() {

return cutCount;

}

/**

*作者:GaoXiaoXiong

*创建时间:2018/4/4

*注释描述:清零

*/

public void clearCount(){

cutCount = 0;

}

/**

*作者:GaoXiaoXiong

*创建时间:2018/4/8

*注释描述:销毁

*/

public void destory(){

if (shortCutBadgerCount!=null){

removeShortcutBadgerACount();

shortCutBadgerCount=null;

}

}

/**

*作者:GaoXiaoXiong

*创建时间:2018/4/8

*注释描述:移除角标和清空统计的角标个数

*/

public void removeShortcutBadgerACount(){

ShortcutBadger.removeCount(ABSApplication.getApplication()); //移除桌面角标

ShortCutBadgerCount.getShortCutBadgerCount().clearCount();//清除个数

}

}

android 小米角标,Android 小米角标无法修改问题研究相关推荐

  1. Android之在app图标添加角标

    在做一些推送服务的时候,想在应用图标上添加未读消息,Android桌面角标的适配确实是非常坑爹的需求.原生系统根本就没有这个功能,国内很多厂家效仿ios都自己定义了该功能. 现在就为大家介绍部分机型添 ...

  2. android 为桌面图标添加数字角标

    android 为桌面图标添加数字角标 我的github项目 BadgeForAppIcon 看完麻烦 star 一下 在某些app的设计中,产品经理总会想当然的提出为桌面图标添加数字角标的需求.作为 ...

  3. android华为推送不显示角标,V6项目集成华为推送流程和角标显示处理

    (一) 集成资料 3.华为官方QQ群:662059980 (二) V6项目集成步骤和代码说明 1.华为官网申请PUSH服务: 1.1申请 点击申请按钮进行申请 1.2提交应用信息 填写应用信息后提交 ...

  4. 小米8 SE和小米9 SE 开源 Android 9 Pie 内核代码

    开发四年只会写业务代码,分布式高并发都不会还做程序员?   近日,小米在 GitHub 开源了小米8 SE和小米9 SE的内核源码(https://github.com/MiCode/Xiaomi_K ...

  5. 小米电视2+android,真实体验小米电视2方便安装第三方软件

    智能电视的普及让我们的客厅变得丰富多彩,2014年推出的小米电视2凭借强劲的硬件以及优秀的体验成为目前市面最为火热的智能电视,基于Android深度定制的MIUI TV在扩展性方面同样表现不俗,通过第 ...

  6. miui android 9q,小米 9 MIUI Android Q Beta 优先体验版正式推送:轻松升级

    7 月 11 日,小米 MIUI 官微宣布,小米 9 MIUI Android Q Beta 优先体验版现已推送!已获得测试资格的小伙伴已经可以升级体验. 换言之已经获得资格的小米 9 用户现在就可以 ...

  7. 小米4降级android版本,小米MIUI不再允许降级,小心手机变砖

    原标题:小米MIUI不再允许降级,小心手机变砖 iOS 11发布之后,苹果开始一点一点的收紧降级通道.每次有新系统更新推送一段时间后,苹果就会关闭老版本系统的验证通道,官方的说法是,这样为了鼓励用户使 ...

  8. 解决小米手机用Android studio安装不了app的问题

    这两天我的小米手机用Android studio直接run的情况下安装不了app.在之前没有出现这种情况.于是查找各种解决办法. 1.INSTALL_FAILED_USER_RESTRICTED错误: ...

  9. android p屏幕使用时间,MIUI迎来第414周更新,新增屏幕使用时间,小米6获Android P更新!...

    原标题:MIUI迎来第414周更新,新增屏幕使用时间,小米6获Android P更新! 今天,我们迎来了本月最后一次MIUI开发版的升级,官方也是在上午的时候如期推送MIUI第414周更新通知,系统版 ...

  10. 小米3刷android 6.0,安卓6.0版MIUI7曝光:小米3/小米4/小米Note将尝鲜

    IT之家讯 12月4日消息,由于可以刷入Win10 Mobile系统,小米手机4在近段时间颇受关注.而在此之前,因为适配该机的MIUI7版本为Android 4.4内核,也引得不少用户吐槽和抱怨.现在 ...

最新文章

  1. Spark技术栈有哪些组件,每个组件都有什么功能,适合什么应用场景?
  2. python培训出来的有公司要吗-python培训机构出来好就业吗
  3. C++实现全局鼠标、键盘消息hook,支持事件
  4. 1.记住密码 提示框
  5. 一个人开始废掉的3种迹象
  6. php中unset面试题,php unset和引用——由一道php面试题引发的思考
  7. 安卓应用用户数据_用户指标数据应用
  8. 动画制作c语言程序,C语言动画制作
  9. Bootstrap3 滚动监听的使用方法
  10. SourceTree的使用
  11. 使用命令行修改当前gnome终端的名称技术
  12. SQL Server 日期+4位流水号
  13. linux监控内存情况同时清理内存脚本
  14. OpenDDS环境搭建-Windows 10
  15. PTES 测试执行标准
  16. ArcGIS教程:启用数据驱动页面
  17. Pandas:用Python做日报(重构)
  18. 浅谈测试工程师必备软技能:沟通表达篇
  19. Android 快递接口
  20. excel多个表格数据汇总之汇总指定名称工作表

热门文章

  1. 全国各地平均工资出炉,北京 IT 人高达13050!你拖后退了吗?
  2. opencv 通过连通域得到外接矩形及外接圆
  3. impdp导入表结构和表数据_EXP COMPRESS以及EXP/IMP EXPDP/IMPDP导入表结构注意-阿里云开发者社区...
  4. 全球半导体业瞬息万变 先进制程加快中国已崛起
  5. 降低数字化转型的“不可控性”:联想智慧服务的解题密码
  6. VTM下载、配置、使用
  7. docker常用软件安装
  8. 品优购静态页面(html+css)——商品详情页
  9. weib后台管理中如何去除横向滚动框
  10. OPENCV3.0打开摄像头或者视频显示画面