2017-09-06 15 views
0

私はこのサービスから通知を送信するメッセージを受信するたびにサーバからの受信メッセージを処理するサービスを持っていますが、残念ながら以前の通知は通知バーの新しい通知によって上書きされます。 これを修正する方法はありますか?これは私のコードです:送信通知はandroidの以前の通知を上書きします

異なる通知のために異なるIDを設定
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

notificationManager.notify(0, n); //ここでは異なるIDを設定します。

+0

すばやく正確な返信をいただきありがとうございます – Programmer

0

すべて同じIDで送信しています。異なるIDを送信すると上書きされません。

関連する問題