お知らせ
このセッションは開発者プレビューのための古い情報です。正式版については
ウェアラブル向けアプリを作る 目次を見てください
目次
Android WearAndroid Wear Developer Previewを始めよう
Android Wear UI概要
Android Wear デザイン原則
Android WearのためのNotificationを作る
Android Wear Notificationから音声入力を受信する
>Android Wear NotificationにPagesを追加する
Android Wear NotificationをStackする
Android Wear Notificationリファレンス(英語)
ライセンス規約(英語)
原文
Android Wear NotificationにPagesを追加する
ユーザーに携帯デバイスでアプリケーションを開かせることなく、より多くの情報を提供したい場合、Android Wear上のNotificationに1Page以上のPagesを加えることが出来ます。追加PageはMain Notificationのすぐ右隣に表示されます。複数Pagesをどうやって使いデザインするかについての情報はAndroid Wear デザイン原則を見てください。


複数のPagesを含むNotificationを作るには、まず携帯やタブレット上で表示されるNotificationを作る方法でメインNotification(最初のPage)を作ることから始めます。
次に、1Page毎にaddPage()メソッドを使うか、addPages()メソッドで複数Pagesが入ったCollectionを使ってください。
例:これはnotificationに2Page目を追加するコードです。
// メインnotificationのためのBuilderを作る
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.new_message)
.setContentTitle("Page 1")
.setContentText("Short message")
.setContentIntent(viewPendingIntent);
// 2Page目のためにBig Textスタイルを作る
BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
secondPageStyle.setBigContentTitle("Page 2")
.bigText("A lot of text...");
// 2Page目のNotifiationを作る
Notification secondPageNotification =
new NotificationCompat.Builder(this)
.setStyle(secondPageStyle)
.build();
// MainNotificationを作り2Page目を追加する
Notification twoPageNotification =
new WearableNotifications.Builder(notificationBuilder)
.addPage(secondPageNotification)
.build();
Except as noted, this content is licensed under Creative Commons Attribution 2.5. For details and restrictions, see the Content License