Example usage for android.app NotificationChannelGroup NotificationChannelGroup

List of usage examples for android.app NotificationChannelGroup NotificationChannelGroup

Introduction

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

Prototype

public NotificationChannelGroup(String id, CharSequence name) 

Source Link

Document

Creates a notification channel group.

Usage

From source file:com.commonsware.android.notify.channel.MainActivity.java

private void initGroups() {
    ArrayList<NotificationChannelGroup> groups = new ArrayList<>();

    groups.add(new NotificationChannelGroup(GROUP_UPDATES, getString(R.string.group_name_updates)));
    groups.add(new NotificationChannelGroup(GROUP_PROMO, getString(R.string.group_name_promo)));

    mgr.createNotificationChannelGroups(groups);
}

From source file:com.keylesspalace.tusky.util.NotificationHelper.java

public static void createNotificationChannelsForAccount(@NonNull AccountEntity account,
        @NonNull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);

        String[] channelIds = new String[] { CHANNEL_MENTION + account.getIdentifier(),
                CHANNEL_FOLLOW + account.getIdentifier(), CHANNEL_BOOST + account.getIdentifier(),
                CHANNEL_FAVOURITE + account.getIdentifier() };
        int[] channelNames = { R.string.notification_channel_mention_name,
                R.string.notification_channel_follow_name, R.string.notification_channel_boost_name,
                R.string.notification_channel_favourite_name };
        int[] channelDescriptions = { R.string.notification_channel_mention_descriptions,
                R.string.notification_channel_follow_description,
                R.string.notification_channel_boost_description,
                R.string.notification_channel_favourite_description };

        List<NotificationChannel> channels = new ArrayList<>(4);

        NotificationChannelGroup channelGroup = new NotificationChannelGroup(account.getIdentifier(),
                account.getFullName());/*w  w w .j  a va2 s . com*/

        //noinspection ConstantConditions
        notificationManager.createNotificationChannelGroup(channelGroup);

        for (int i = 0; i < channelIds.length; i++) {
            String id = channelIds[i];
            String name = context.getString(channelNames[i]);
            String description = context.getString(channelDescriptions[i]);
            int importance = NotificationManager.IMPORTANCE_DEFAULT;
            NotificationChannel channel = new NotificationChannel(id, name, importance);

            channel.setDescription(description);
            channel.enableLights(true);
            channel.setLightColor(0xFF2B90D9);
            channel.enableVibration(true);
            channel.setShowBadge(true);
            channel.setGroup(account.getIdentifier());
            channels.add(channel);
        }

        //noinspection ConstantConditions
        notificationManager.createNotificationChannels(channels);

    }
}

From source file:com.ruesga.rview.misc.NotificationsHelper.java

@TargetApi(Build.VERSION_CODES.O)
public static void createNotificationChannel(Context context, Account account) {
    if (AndroidHelper.isApi26OrGreater()) {
        final String defaultChannelName = context.getString(R.string.notifications_default_channel_name,
                account.getRepositoryDisplayName(), account.getAccountDisplayName());
        final NotificationManager nm = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        nm.createNotificationChannelGroup(
                new NotificationChannelGroup(account.getAccountHash(), defaultChannelName));

        NotificationChannel channel = new NotificationChannel(account.getAccountHash(), defaultChannelName,
                NotificationManager.IMPORTANCE_DEFAULT);
        channel.setDescription(context.getString(R.string.notifications_default_channel_description));
        channel.enableVibration(true);//from   ww w .  j  av  a 2  s  . c o m
        channel.enableLights(true);
        channel.setLightColor(ContextCompat.getColor(context, R.color.primaryDark));
        channel.setShowBadge(true);
        channel.setGroup(account.getAccountHash());
        nm.createNotificationChannel(channel);
    }
}

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

public void addNotificationGroup(int id, String name) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        ((NotificationManager) IRCCloudApplication.getInstance().getApplicationContext()
                .getSystemService(Context.NOTIFICATION_SERVICE))
                        .createNotificationChannelGroup(new NotificationChannelGroup(String.valueOf(id), name));
    }//from w w w  .  ja  va  2s .  c  o  m
}