Example usage for android.app NotificationManager getNotificationChannelGroups

List of usage examples for android.app NotificationManager getNotificationChannelGroups

Introduction

In this page you can find the example usage for android.app NotificationManager getNotificationChannelGroups.

Prototype

public List<NotificationChannelGroup> getNotificationChannelGroups() 

Source Link

Document

Returns all notification channel groups belonging to the calling app.

Usage

From source file:com.irccloud.android.data.collection.NotificationsList.java

public void pruneNotificationChannels() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager nm = ((NotificationManager) IRCCloudApplication.getInstance()
                .getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE));

        for (NotificationChannelGroup c : nm.getNotificationChannelGroups()) {
            try {
                if (ServersList.getInstance().getServer(Integer.valueOf(c.getId())) == null)
                    nm.deleteNotificationChannelGroup(c.getId());
            } catch (NumberFormatException e) {
            }/* w w w.  j  a v  a2 s .c o m*/
        }

        for (NotificationChannel c : nm.getNotificationChannels()) {
            try {
                if (BuffersList.getInstance().getBuffer(Integer.valueOf(c.getId())) == null)
                    nm.deleteNotificationChannel(c.getId());
            } catch (NumberFormatException e) {
            }
        }
    }
}