W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
編寫:wangyachen - 原文:http://developer.android.com/training/wearables/notifications/pages.html
當(dāng)開發(fā)者想要在不需要用戶在他們的手機(jī)上打開app的情況下,還可以允許表達(dá)更多的信息,那么開發(fā)者可以在可穿戴設(shè)備上的Notification中添加一個(gè)或多個(gè)的頁面。添加的頁面會馬上出現(xiàn)在主 Notification 卡片的右邊。
為了創(chuàng)建一個(gè)擁有多個(gè)頁面的 Notification,開發(fā)者需要:
舉個(gè)例子,以下代碼為Notification添加了第二個(gè)頁面:
// 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();
// Add second page with wearable extender and extend the main notification
Notification twoPageNotification =
new WearableExtender()
.addPage(secondPageNotification)
.extend(notificationBuilder)
.build();
// Issue the notification
notificationManager =
NotificationManagerCompat.from(this);
notificationManager.notify(notificationId, twoPageNotification);
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: