美文网首页
小米角标

小米角标

作者: yahzon | 来源:发表于2018-02-21 17:36 被阅读26次

    https://github.com/leolin310148/ShortcutBadger/blob/master/SampleApp/src/main/java/me/leolin/shortcutbadger/example/BadgeIntentService.java

    http://blog.csdn.net/andylao62/article/details/41794695

    http://blog.csdn.net/janice0529/article/details/44344169

    http://blog.csdn.net/Zophar_Development/article/details/78801919

    踩坑 http://blog.csdn.net/qq_29678299/article/details/51759516
    项目:https://github.com/lixiangers/BadgeUtil
    private static void sendToXiaoMi(Context context, int count) {
    try {
    Class miuiNotificationClass = Class.forName("android.app.MiuiNotification");
    Object miuiNotification = miuiNotificationClass.newInstance();
    Field field = miuiNotification.getClass().getDeclaredField("messageCount");
    field.setAccessible(true);
    field.set(miuiNotification, String.valueOf(count == 0 ? "" : count)); // 设置信息数-->这种发送必须是miui 6才行
    } catch (Exception e) {
    e.printStackTrace();
    // miui 6之前的版本
    Intent localIntent = new Intent(
    "android.intent.action.APPLICATION_MESSAGE_UPDATE");
    localIntent.putExtra(
    "android.intent.extra.update_application_component_name",
    context.getPackageName() + "/" + getLauncherClassName(context));
    localIntent.putExtra(
    "android.intent.extra.update_application_message_text", String.valueOf(count == 0 ? "" : count));
    context.sendBroadcast(localIntent);
    }
    }

    相关文章

      网友评论

          本文标题:小米角标

          本文链接:https://www.haomeiwen.com/subject/sejotftx.html