为通知添加更多页面(Adding Pages to a Notification)
来源:互联网 发布:软件服务协会 编辑:程序博客网 时间:2024/05/19 19:32
为通知添加更多页面(Adding Pages to a Notification)
当你想提供更多的信息,而这些信息不需要用户打开手机去查看,此时你可以添加一个或者多个页面在wear的通知中.更多的页面内容会立即呈现在主通知卡片的右侧.
通过以下步骤创建拥有多个页面的通知:
- 首先使用NotificationCompat.Builder创建一个主通知,这里创建的通知和展示在手机上的通知创建方式一样.
- 使用NotificationCompat.Builder为通知创建更多的页面.
- 使用方法addPage()或者addPages()讲创建的页面添加到主通知中.
举个栗子,下面是添加第二个页面到通知中的代码.
// Create builder for the main notificationNotificationCompat.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 pageBigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();secondPageStyle.setBigContentTitle("Page 2") .bigText("A lot of text...");// Create second page notificationNotification secondPageNotification = new NotificationCompat.Builder(this) .setStyle(secondPageStyle) .build();// Extend the notification builder with the second pageNotification notification = notificationBuilder .extend(new NotificationCompat.WearableExtender() .addPage(secondPageNotification)) .build();// Issue the notificationnotificationManager = NotificationManagerCompat.from(this);notificationManager.notify(notificationId, notification);
0 0
- 为通知添加更多页面(Adding Pages to a Notification)
- Android Wear Preview- 为通知添加多个页面(Adding Pages to a Notification)
- android Wearable-Adding Pages to a Notification and Stacking Notifications
- Android Wear 进阶 1 Adding Wearable Features to Notifications 添加手表特性到通知上
- Adding static blocks to specific CMS pages with Magento layouts
- Adding Content to a Document
- How To Adding Help to a Service Provider Property Page(添加服务提供程序属性页)
- Adding a Floating Panel to a Window
- [R] adding a title to a histogram
- Adding a Single Task to a Queue
- Adding Shadows to Shapes(添加阴影)
- iphone 如何添加本地通知(local notification)
- iphone 如何添加本地通知(local notification)
- Adding a JDBC driver to JBuilder
- Dynamically Adding Controls to a Web Page...
- Adding Controls to a DataGrid at Runtime
- Adding an Unsupported Language to a Project
- Dynamically Adding Template columns to a GridView
- Android状态栏之沉浸式模式
- BackhaulRateDlWLAN 和BackhaulRateUlWLAN WLAN回程线路上行和下行带宽
- SSID、BSSID、ESSID
- 贪心算法举例分析
- 切换流程(WLAN->E-UTRAN)
- 为通知添加更多页面(Adding Pages to a Notification)
- Scala之小括号和花括号(Parentheses & Crurly Braces)
- 切换流程-空口信令
- iOS 对RunTime的一些简单了解
- 切换流程-IMS/SIP信令(wireshark信令)
- IPSEC建立过程
- 简单RPC之Socket实现
- LTE SystemInformationBlockType17
- PHP文件上传类(支持单文件上传,也支持多文件上传)