2015-06-14 99 views
0

通知我需要在WhatsApp的實現Android Wear的通知等,其中每個對話是一個列表,並向右滑動允許用戶回覆到各自的談話。我嘗試從android開發人員示例堆疊,但它只顯示消息。我怎麼能設置超過1條消息,並像whatsapp中的相應操作?WhatsApp的像Android的磨損

編輯:

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

我沒有做單獨的可穿戴式模塊,而是,我只是發送通知磨損。代碼無論如何都是添加的 – Vijai

回答

1

你基本上是缺失的三種不同的東西:

  1. 你是不是叫setGroup("GROP_NAME")NotificationBuilder
  2. 通知屬於同一組必須有不同的ID。如果你在你的情況下,同一個ID,NOTIFICATION_ID總是通知,STE堆疊將無法正常工作
  3. 你想爲每個通知不同replyPendingIntent,否則你的意圖將把通知的最後通知。爲每個通知傳遞一個不同的值,而不是硬編碼0

其餘的看起來不錯,

+0

謝謝你指出。那麼,我將不得不爲每個對話分配不同的通知ID,然後通知它? – Vijai

+0

對話和待處理意圖的不同ID – Blackbelt

+0

再次感謝您。要花一些時間來做出改變。一旦我做了更改,會讓你知道結果。 – Vijai