プレビューから使用しようとしてPages
います。コードがないと通知は正常に表示されますが、特定のコードを使用すると、電話でも. 私はコードを 10 回調べましたが、エラーを見つけるには新鮮な目が必要だと思います。Stacks
Android Wear SDK
Wear
Wear
Wear Emulator
このコードは、 ( を使用して)未読のリストを含むNotification
for each Tracker
( を送信する外部デバイス) を電話で作成する必要があります。でグループ化された複数の をスタックし、各 unreadにを追加します。Message
Message
InboxStyle
Wear
Notification
Tracker
Page
Message
public static void showNewMessagesNotif(Context context, Tracker tracker, List<Message> messages) {
String trackerName = tracker.getName() + " - " + tracker.getPhoneNumber();
String contentTitle = context.getResources().getQuantityString(R.plurals.notif_new_messages, messages.size(), messages.size());
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + tracker.getPhoneNumber()));
PendingIntent callPendingIntent = PendingIntent.getActivity(context, 0, callIntent, 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_action_location_searching)
.setContentTitle(contentTitle)
.setContentText(trackerName)
.setAutoCancel(true)
.addAction(R.drawable.ic_action_call, context.getString(R.string.action_call), callPendingIntent);
NotificationCompat.InboxStyle inboxStyle =
new NotificationCompat.InboxStyle();
// Sets a title for the Inbox style big view
inboxStyle.setBigContentTitle(contentTitle);
// Moves events into the big view
for (Message message : messages) {
inboxStyle.addLine(message.getText());
}
inboxStyle.setSummaryText(trackerName);
// Moves the big view style object into the notification object.
mBuilder.setStyle(inboxStyle);
mBuilder.setContentIntent(getNotificationIntent(context, tracker));
// Issue the notification here.
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(context);
int notifId = (int) (NEW_MESSAGE_NOTIF_BASE_ID + tracker.getRowId());
//Android Wear Notifications
List<Notification> wearPages = new ArrayList<Notification>();
for (Message message : messages) {
NotificationCompat.BigTextStyle extraPageStyle = new NotificationCompat.BigTextStyle();
extraPageStyle.setBigContentTitle(message.getText())
.bigText(message.getAddress());
Notification extraPageNotification = new NotificationCompat.Builder(context)
.setStyle(extraPageStyle)
.build();
wearPages.add(extraPageNotification);
}
WearableNotifications.Builder wearNotificationBuilder =
new WearableNotifications.Builder(mBuilder)
.setHintHideIcon(true)
.setGroup(GROUP_BY_TRACKER).addPages(wearPages);
// mId allows you to update the notification later on.
notificationManager.notify(notifId, wearNotificationBuilder.build());
}