2017-09-06 44 views
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

回答

1

設置不同的ID爲不同的通知。

notificationManager.notify(0, n); //這裏設置了不同的ID。

+0

感謝您的快速和正確答覆 – Programmer

0

你發送它們全部使用相同的ID。發送不同的ID,他們不會覆蓋。