What is correct way to put notifications into stack as in Telegram in android Oreo?

Viewed 311

I have an example app that can to group notifications as in the Telegram messenger.

The build build tools is 26.0.2. Compile and target SDK verions are 27. For API 26 and above I added some code in onViewCreated() method :

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    NotificationChannelGroup group = new NotificationChannelGroup(NOTIFICATION_GROUP, "messages");
    mNotificationManager.createNotificationChannelGroup(group);

    NotificationChannel channel = new NotificationChannel("channel_some", "channel_some", NotificationManager.IMPORTANCE_HIGH);
    channel.enableLights(true);
    channel.setGroup(NOTIFICATION_GROUP);
    mNotificationManager.createNotificationChannel(channel);
}

And use other constructor with notification channel id to create NotificationCompat.Builder:

final NotificationCompat.Builder builder = new NotificationCompat.Builder(getActivity(), "channel_some")

But notifications are not grouped as it was in API 24 and 25. Which way is correct to group different notifications (example - Telegram messenger) in API 26 and above?

UPDATE: It example works with compile and target SDK of 25 version. How to use it with SDK of 26 version and above?

0 Answers
Related