小米角标

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

你可能感兴趣的:(小米角标)