繁体   English   中英

多个通知在Android上不起作用

[英]Multiple notifications not working on Android

每当我在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);

谢谢

为不同的通知设置不同的ID。

notificationManager.notify(0, n); //在此设置不同的ID。

您要发送的所有ID都相同。 发送不同的ID,它们不会被覆盖。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM