List of usage examples for android.app NotificationManager areNotificationsEnabled
public boolean areNotificationsEnabled()
From source file:com.keylesspalace.tusky.util.NotificationHelper.java
public static boolean areNotificationsEnabled(@NonNull Context context, @NonNull AccountManager accountManager) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // on Android >= O, notifications are enabled, if at least one channel is enabled NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); //noinspection ConstantConditions if (notificationManager.areNotificationsEnabled()) { for (NotificationChannel channel : notificationManager.getNotificationChannels()) { if (channel.getImportance() > NotificationManager.IMPORTANCE_NONE) { Log.d(TAG, "NotificationsEnabled"); return true; }//from w ww. ja va 2s . co m } } Log.d(TAG, "NotificationsDisabled"); return false; } else { // on Android < O, notifications are enabled, if at least one account has notification enabled return accountManager.areNotificationsEnabled(); } }