为通知添加更多页面(Adding Pages to a Notification)
当你想提供更多的信息,而这些信息不需要用户打开手机去查看,此时你可以添加一个或者多个页面在wear的通知中.更多的页面内容会立即呈现在主通知卡片的右侧.
// Create builder for the main notification
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.new_message)
.setContentTitle("Page 1")
.setContentText("Short message")
.setContentIntent(viewPendingIntent);
// Create a big text style for the second page
BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
secondPageStyle.setBigContentTitle("Page 2")
.bigText("A lot of text...");
// Create second page notification
Notification secondPageNotification =
new NotificationCompat.Builder(this)
.setStyle(secondPageStyle)
.build();
// Extend the notification builder with the second page
Notification notification = notificationBuilder
.extend(new NotificationCompat.WearableExtender()
.addPage(secondPageNotification))
.build();
// Issue the notification
notificationManager =
NotificationManagerCompat.from(this);
notificationManager.notify(notificationId, notification);