package com.hdl.photovoltaic.utils; import android.app.NotificationManager; import android.content.Context; import me.leolin.shortcutbadger.ShortcutBadger; public class BadgeUtils { // 设置角标数量 public static void setBadgeCount(Context context, int count) { if (ShortcutBadger.isBadgeCounterSupported(context)) { ShortcutBadger.applyCount(context, count); } } // 清除角标(设置数量为0) public static void clearBadge(Context context) { if (ShortcutBadger.isBadgeCounterSupported(context)) { ShortcutBadger.removeCount(context); } else { // 备用方案 // clearBadgeByManufacturer(context); } } /** * 清除所有通知 */ public static void cancelAllNotifications(Context context) { NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancelAll(); } }