add number of notifications to badge
This commit is contained in:
parent
51198f5b69
commit
9abf9d3891
|
@ -32,9 +32,11 @@ public class ForegroundService extends Service {
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationManager notificationManager =
|
||||
context.getSystemService(NotificationManager.class);
|
||||
notificationManager.createNotificationChannel(new NotificationChannel(CHANNEL_ID,
|
||||
"Status Service",
|
||||
NotificationManager.IMPORTANCE_HIGH));
|
||||
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
|
||||
"Status Service",
|
||||
NotificationManager.IMPORTANCE_HIGH);
|
||||
channel.setShowBadge(false);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
Class intentClass;
|
||||
String packageName = context.getPackageName();
|
||||
|
@ -63,6 +65,7 @@ public class ForegroundService extends Service {
|
|||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setNumber(0)
|
||||
.addAction(R.drawable.ic_stat_notify_status, "STOP", stopPendingIntent)
|
||||
.build();
|
||||
// the id of the foreground notification MUST NOT be 0
|
||||
|
|
|
@ -166,6 +166,7 @@ public class NewMessageSignalHandler {
|
|||
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
|
||||
.build();
|
||||
channel.setSound(soundUri, audioAttributes);
|
||||
channel.setShowBadge(true);
|
||||
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
@ -205,6 +206,7 @@ public class NewMessageSignalHandler {
|
|||
.setGroupSummary(true)
|
||||
.setContentIntent(createOnTapIntent(context, notificationId, chat.getId()))
|
||||
.setDeleteIntent(createOnDismissedIntent(context, notificationId, chat.getId()))
|
||||
.setNumber(messages.size())
|
||||
.setAutoCancel(true);
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
builder.setVibrate(new long[0]);
|
||||
|
|
Loading…
Reference in New Issue