我需要在whatsapp中实现android的通知,其中每个会话都是一个列表,向右滑动允许用户回复相应的会话。我尝试从Android开发人员示例堆叠,但它只按原样显示消息。如何在whatsapp中设置多条消息和相应的操作?
编辑:
NotificationCompat.WearableExtender wearOptions =
new NotificationCompat.WearableExtender()
.setHintHideIcon(true);
String replyLabel = mXmppConnectionService.getResources().getString(R.string.wear_reply);
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
.setLabel(replyLabel)
.build();
Intent replyIntent = new Intent(mXmppConnectionService, XmppConnectionService.class);
PendingIntent replyPendingIntent =
PendingIntent.getActivity(mXmppConnectionService, 0, replyIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action action =
new NotificationCompat.Action.Builder(R.mipmap.ic_launcher,
"reply to", replyPendingIntent)
.addRemoteInput(remoteInput)
.build();
final Builder mBuilder;
mBuilder.setDefaults(0);
mBuilder.setSmallIcon(R.drawable.ic_notification);
mBuilder.setPriority(getPriority());
mBuilder.setDeleteIntent(createDeleteIntent());
mBuilder.setLights(0xff00FF00, 2000, 3000)
.extend(wearOptions)
.extend(new NotificationCompat.WearableExtender().addAction(action));
final Notification notification = mBuilder.build();
notificationManager.notify(NOTIFICATION_ID, notification);
答案 0 :(得分:1)
你基本上缺少三件事:
setGroup("GROP_NAME")
NotificationBuilder
NOTIFICATION_ID
,则无法使用堆叠replyPendingIntent
,否则您的待处理意图将引用最后通知的通知。而不是硬编码0
,为每个通知传递不同的值。 其余的看起来不错,