phone 上也显示了 Stacked Wear 通知
Stacked Wear notification shown on phone too
我有 1 个摘要通知和几个堆叠通知。
由于某种原因,堆叠通知不仅显示在
Andrid Wear 设备也上了phone。
根据文档
Stacking Notifications
它们应该只显示在手表上。
NotificationBuilder.setGroup 当然设置为相同的值,并且只有摘要具有 .setSummary(true)。
详情:
http://marcuswolschon.blogspot.de/2015/05/implementing-k9-mail-wear-support.html
将 NotificationManager 替换为 NotificationManagerCompat
使用NotificationManager
private void send() {
Notification notification1 =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("News1")
.setGroup("News")
.setContentText("Text")
.build();
Notification notification2 =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("News2")
.setGroup("News")
.setContentText("Text2")
.build();
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(1 , notification1);
notificationManager.notify(2 , notification2);
Notification Summary = new NotificationCompat.Builder(this)
.setContentTitle("2 new News")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText("Text2")
.setGroup("News")
.setGroupSummary(true)
.build();
notificationManager.notify(-1 , Summary);
}
使用NotificationManagerCompat
private void send() {
Notification notification1 =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("News1")
.setGroup("News")
.setContentText("Text")
.build();
Notification notification2 =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("News2")
.setGroup("News")
.setContentText("Text2")
.build();
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(this);
notificationManager.notify(1 , notification1);
notificationManager.notify(2 , notification2);
Notification Summary = new NotificationCompat.Builder(this)
.setContentTitle("2 new News")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText("Text2")
.setGroup("News")
.setGroupSummary(true)
.build();
notificationManager.notify(-1 , Summary);
}
我有 1 个摘要通知和几个堆叠通知。 由于某种原因,堆叠通知不仅显示在 Andrid Wear 设备也上了phone。 根据文档 Stacking Notifications 它们应该只显示在手表上。 NotificationBuilder.setGroup 当然设置为相同的值,并且只有摘要具有 .setSummary(true)。
详情: http://marcuswolschon.blogspot.de/2015/05/implementing-k9-mail-wear-support.html
将 NotificationManager 替换为 NotificationManagerCompat
使用NotificationManager
private void send() {
Notification notification1 =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("News1")
.setGroup("News")
.setContentText("Text")
.build();
Notification notification2 =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("News2")
.setGroup("News")
.setContentText("Text2")
.build();
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(1 , notification1);
notificationManager.notify(2 , notification2);
Notification Summary = new NotificationCompat.Builder(this)
.setContentTitle("2 new News")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText("Text2")
.setGroup("News")
.setGroupSummary(true)
.build();
notificationManager.notify(-1 , Summary);
}
使用NotificationManagerCompat
private void send() {
Notification notification1 =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("News1")
.setGroup("News")
.setContentText("Text")
.build();
Notification notification2 =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("News2")
.setGroup("News")
.setContentText("Text2")
.build();
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(this);
notificationManager.notify(1 , notification1);
notificationManager.notify(2 , notification2);
Notification Summary = new NotificationCompat.Builder(this)
.setContentTitle("2 new News")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText("Text2")
.setGroup("News")
.setGroupSummary(true)
.build();
notificationManager.notify(-1 , Summary);
}