• MIUI6&7桌面角标开源代码简介


    MIUI6&7桌面角标开源代码简介

    MIUI6&7上重新设计了桌面app图标的角标显示,基本规则如下:

    一、基本介绍

    1、默认的情况

    当app 向通知栏发送了一条通知 (通知不带进度条并且用户可以删除的),那么桌面app icon角标就会显示1.此时app显示的角标数是和通知栏里app发送的通知数对应的,即向通知栏发送了多少通知就会显示多少角标。

    2、通知可以定义角标数

    例如 有5封未读邮件,通知栏里只会显示一条通知,但是想让角标显示5. 可以在发通知时加个标示。

    二、实现代码

    第三方app需要用反射来调用,参考代码:

    NotificationManager mNotificationManager = (NotificationManager) this

    .getSystemService(Context.NOTIFICATION_SERVICE);

    Notification.Builder builder = new Notification.Builder(this)

    .setContentTitle(“title”).setContentText(“text”).setSmallIcon(R.drawable.icon);

    Notification notification = builder.build();

    try {

    Field field = notification.getClass().getDeclaredField(“extraNotification”);

    Object extraNotification = field.get(notification);

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

    method.invoke(extraNotification, mCount);

    } catch (Exception e) {

    e.printStackTrace();

    }

    mNotificationManager.notify(0,notification);

  • 相关阅读:
    基于FPGA的ARP协议实现
    Modelsim 仿真错误集锦
    基于FPGA的IIC驱动设计
    状态机跑飞的解决办法
    基于FPGA的检测时钟脉冲的高电平及低电平的中点标志位设计
    基于FPGA的UART实现
    基于FPGA的数字秒表设计
    Matlab的常用调试方法
    基于FPGA的花样流水灯
    **time_limited.sof文件
  • 原文地址:https://www.cnblogs.com/dongweiq/p/4992686.html
Copyright © 2020-2023  润新知