[英]Whatsapp like notification in android wear
我需要像在whatsapp中那樣在Android Wear中實現通知,其中每個對話都是一個列表,向右滑動可讓用戶回復相應的對話。 我嘗試從android開發人員示例進行堆疊,但僅按原樣顯示消息。 如何設置超過1條消息以及類似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);
您實際上缺少了三件事:
NotificationBuilder
上調用setGroup("GROP_NAME")
NOTIFICATION_ID
,則Ste stack無效 replyPendingIntent
,否則您的待處理意圖將引用最后通知的通知。 而不是硬編碼0
,而是為每個通知傳遞不同的值。 其余的看起來不錯,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.