0
如果應用程序已打開,但無法關閉應用程序時,堆疊的通知將生效。如果應用程序關閉,圖標不正確,通知未堆疊?堆疊的通知無法在關閉的應用程序上工作
這裏是我的代碼:
notification = new NotificationCompat.Builder(this);
notification.setContentTitle(notifyFromName);
notification.setContentText(notifyMsg);
if (!msgIsProj) {
String followText = notifyMsg + " you!";
notification.setContentText(followText);
notification.setGroup(GROUP_KEY_FOLLOWERS);
Log.d(Constants.DEBUG, "SETTING AS FOLLOWers" + unread_notif);
} else {
notification.setContentText(notifyMsg + " " + notifyItemName);
notification.setGroup(GROUP_KEY_PROJECTS);
}
notification.setTicker(getString(R.string.titlePushNotify));
notification.setSmallIcon(R.drawable.ic_pushnotify);
//notification.setGroupSummary(true);
PendingIntent contentIntent = PendingIntent.getActivity(this, id,
newIntentMsg, PendingIntent.FLAG_CANCEL_CURRENT);
notification.setContentIntent(contentIntent);
notification.setAutoCancel(true);
manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if(notifyMsg != null && !notifyMsg.equals("")) {
manager.notify(id, notification.build());
unread_notif++;
Log.d(Constants.DEBUG, "PRE MORE NOTIF" + unread_notif);
if (unread_notif>1) {
Log.d(Constants.DEBUG, "GETTING MORE NOTIF" + unread_notif);
Notification summaryNotification = new NotificationCompat.Builder(this)
.setContentTitle("Your summary message")
.setSmallIcon(R.drawable.ic_pushnotify)
.setStyle(new NotificationCompat.InboxStyle()
.addLine("Details about your first notification")
.addLine("Details about your second notification")
.setBigContentTitle(Integer.toString(unread_notif)+" new notifications")
.setSummaryText("More details in app"))
.setGroup(GROUP_KEY_FOLLOWERS)
.setGroupSummary(true)
.build();
manager.notify(id++, summaryNotification);
}
}