我正在尝试Notify
根据一些标准来使用用户。Multiple Notifications
正在显示,Status Bar
但我想当Group the notification in single notification
用户点击 时Status Bar
,我想检索该组中的所有通知。那可能吗?或者我必须维护PendingIntents
这些通知?任何帮助将不胜感激。例如,如果两个朋友的生日在同一天,则应显示 2 条通知。我想组合这些通知,即,而不是状态栏中的 2 个通知,我想要一个,当用户单击它时,它应该有关于 2 个通知的信息。可能吗?
请参阅下面的代码以显示通知。
public void displayNotification(BirthdayDetail detail)
{
NotificationCompat.Builder builder = new NotificationCompat.Builder(this.context);
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setContentTitle(detail.getContactName());
builder.setContentText(detail.getContactBirthDate());
Intent resultIntent = new Intent(this.context, NotificationView.class);
resultIntent.putExtra("name", detail.getContactName());
resultIntent.putExtra("birthdate", detail.getContactBDate());
resultIntent.putExtra("picture_path", detail.getPicturePath());
resultIntent.putExtra("isContact", detail.isFromContact());
resultIntent.putExtra("notificationId", notificationId);
if(detail.isFromContact())
{
resultIntent.putExtra("phone_number", detail.getPhoneNumber());
}
PendingIntent resultPendingIntent = PendingIntent.getActivity(this.context, requestCode++,
resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
notificationManager
= (NotificationManager) this.context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notificationId, builder.build());
notificationId++;
}