0
我有一個處理從服務器接收消息的服務,每當我收到一封消息時,我都會通過此服務發送通知,但不幸的是之前的通知已被通知欄中的新通知覆蓋。 任何想法解決這個問題?這是我的代碼:發送通知覆蓋android中的以前通知
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
Intent intent = new Intent(DbInsertService.this, MessageActivity.class);
intent.putExtra("Service",serviceType);
PendingIntent pIntent = PendingIntent.getActivity(DbInsertService.this, (int)
System.currentTimeMillis(), intent,PendingIntent.FLAG_UPDATE_CURRENT);
Notification n = new Notification.Builder(DbInsertService.this)
.setContentTitle("Message from " +serviceType.getSer_name())
.setContentText(messageType.getHis_title())
.setSmallIcon(R.drawable.ic_email_variant_grey600_24dp)
.setContentIntent(pIntent)
.setAutoCancel(true).build();
notificationManager.notify(0, n);
thansk
感謝您的快速和正確答覆 – Programmer