我正在尝试在我的手机上接收多个通知。但是每次我发送通知时。以前的通知都会被新通知覆盖。我看了其他问题,他们说有多个Id's
通知我也在这样做,但我没有'不知道我哪里错了。
这是我创建通知的方式。(它是在服务中创建的)。
private void GenerateNotification(String data)
{
String ns=Context.NOTIFICATION_SERVICE;
manager=(NotificationManager) getSystemService(ns);
int icon=R.drawable.ic_launcher;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, data, when);
notification.flags |=Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
Context context = getApplicationContext();
CharSequence contentTitle = "The Best Essay";
CharSequence contentText = data;
Intent notificationIntent = new Intent(this,MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
manager.notify(HELLO_ID, notification);
HELLO_ID++;
}
HelloID 在哪里增加以接收具有唯一 ID 的多个通知。请告诉我我做错了什么。