Android Wear Preview- 为通知添加多个页面(Adding Pages to a Notification)
2014-06-24 12:46
519 查看
----------------------------------------------------------------------------------------------------------------------------------------------------------
原文作者:Google
原文地址:http://developer.android.com/wear/notifications/pages.html
原文版权:Creative Commons 2.5 Attribution License
译文作者:Jianan - qinxiandiqi@foxmail.com
版本信息:本文基于2014-06-24版本翻译
译文版权:CC BY-NC-ND 4.0,允许复制转载,但必须保留译文作者署名及译文链接,不得演绎和用于商业用途
----------------------------------------------------------------------------------------------------------------------------------------------------------
当你想要提供更多的信息又不想要求用户在手持设备上打开你的应用程序,你可以选择在Android Wear设备上为你的通知添加一个多个Page(页面)。附加的页面会立刻显示在主通知卡片的右边。更多关于如何使用和设计多页面的内容,请参考Design Principles of Android Wear。
当创建一个多页面的通知,从创建主通知(第一个页面),也就是你希望显示在手机或者平板上的通知开始。然后,使用addPage()方法一次添加一个页面,或者使用addPages()一次传递一个包含过个页面的Collection集合进去。
例如,下面的代码添加为通知添加了第二个页面:
// 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();
// Create main notification and add the second page
Notification twoPageNotification =
new WearableNotifications.Builder(notificationBuilder)
.addPage(secondPageNotification)
.build();
原文作者:Google
原文地址:http://developer.android.com/wear/notifications/pages.html
原文版权:Creative Commons 2.5 Attribution License
译文作者:Jianan - qinxiandiqi@foxmail.com
版本信息:本文基于2014-06-24版本翻译
译文版权:CC BY-NC-ND 4.0,允许复制转载,但必须保留译文作者署名及译文链接,不得演绎和用于商业用途
----------------------------------------------------------------------------------------------------------------------------------------------------------
当你想要提供更多的信息又不想要求用户在手持设备上打开你的应用程序,你可以选择在Android Wear设备上为你的通知添加一个多个Page(页面)。附加的页面会立刻显示在主通知卡片的右边。更多关于如何使用和设计多页面的内容,请参考Design Principles of Android Wear。
当创建一个多页面的通知,从创建主通知(第一个页面),也就是你希望显示在手机或者平板上的通知开始。然后,使用addPage()方法一次添加一个页面,或者使用addPages()一次传递一个包含过个页面的Collection集合进去。
例如,下面的代码添加为通知添加了第二个页面:
// 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();
// Create main notification and add the second page
Notification twoPageNotification =
new WearableNotifications.Builder(notificationBuilder)
.addPage(secondPageNotification)
.build();
相关文章推荐
- 为通知添加更多页面(Adding Pages to a Notification)
- AndroidWear 添加多页面到通知
- android Wearable-Adding Pages to a Notification and Stacking Notifications
- Android 主页面顶部栏的通知Notification ,可以自定义通知消息栏的风格,并且点击通知栏进人本程序。
- Android Wear 进阶 1 Adding Wearable Features to Notifications 添加手表特性到通知上
- Android 创建通知Notification,并返回到主页面的那些事
- Android添加顶部通知(Notification)并处于“正在进行中”(onGoing)
- 使用UILocalNotification 添加本地通知事件
- 【Android】状态栏通知Notification、NotificationManager详解
- 从J2EE转向Android的第十天-----对话框(Dialog)和通知(Notification)
- Android开发——通知Notification
- Adding a library/JAR to an Eclipse Android project
- android之Notification通知
- 系出名门Android(3) - 对话框(Dialog)和通知(Notification)
- Android中的通知—Notification
- Android下Notification(通知栏)的使用
- 怎么添加简易页面ezpages?
- 定制android通知(Notification)
- How To Adding Help to a Service Provider Property Page(添加服务提供程序属性页)
- 系出名门Android(3) - 对话框(Dialog)和通知(Notification)