【发布时间】:2020-04-19 16:45:21
【问题描述】:
我的群组通知工作正常,但是,我注意到几个小时后(一段时间不使用设备时)当有新通知来时,当通知展开时消息内容消失,即@ 987654327@ 文字消失。我知道这不是请求代码问题,因为所有请求代码都是唯一的,我可以正常回复通知。
需要注意的是,在通知消失后,下一个通知,如果设备处于活动状态(不一定是应用程序),则该通知在展开时将显示其正常文本。这似乎仅在设备和/或应用程序一段时间未使用时才会发生。这是安卓系统的问题吗?
下面是描述行为的图片快照:
第一次通知
第二个通知进来了。
展开两个通知,您可以看到它们的所有消息都消失了。
代码:请注意,我只发送一次摘要通知。
// Normal notification
int uniqueRequestCode = RandomUser.getUniqueRequestCode();
PendingIntent pendingIntent = PendingIntent.getActivity(
this, uniqueRequestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notificatio notification = new NotificationCompat.Builder(getApplicationContext(), MESSAGE_CHANNEL_ID)
.setSmallIcon(R.drawable.ne1_white_logo_crop)
.setContentTitle(title)
.setContentText(body)
.setStyle(new NotificationCompat.BigTextStyle().bigText(body))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
// Set the intent that will fire when the user taps the notification
.setContentIntent(pendingIntent)
.addAction(action)
.setGroup(GROUP_KEY_MESSAGE)
//.setGroupAlertBehavior(groupAlert)
.setColor(Color.BLACK)
.setAutoCancel(true)
.build();
// Summary notification
uniqueRequestCode = RandomUser.getUniqueRequestCode();
PendingIntent pendingIntent = PendingIntent.getActivity(
this, uniqueRequestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification summaryNotification = new NotificationCompat.Builder(this, MESSAGE_CHANNEL_ID)
.setSmallIcon(R.drawable.ne1_white_logo_crop)
// Specify which group this notification belongs to
.setGroup(GROUP_KEY_MESSAGE)
// Set this notification as the summary for the group
.setGroupSummary(true)
.setContentIntent(pendingIntent)
.build();
【问题讨论】:
标签: android android-intent android-notifications