Skip to content

Instantly share code, notes, and snippets.

@Aiur3908
Created May 4, 2015 07:19
Show Gist options
  • Save Aiur3908/3d134025c04ced910794 to your computer and use it in GitHub Desktop.
Save Aiur3908/3d134025c04ced910794 to your computer and use it in GitHub Desktop.
private void sendNotification() {
int notificationId = 001;
//決定這個notification的辨識編號
NotificationCompat.Builder notifcaition =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("標題")
.setContentText("內容");
//創建一個主要的Notification物件
NotificationCompat.Builder secondPageNotification =
new NotificationCompat.Builder(this)
.setContentTitle("我是第二頁")
.setContentText("第二頁的內容");
//創建第二頁的Notification物件
notifcaition.extend(new NotificationCompat.WearableExtender().addPage(secondPageNotification.build()));
//用主要的Notification物件加入第二頁的內容
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this);
//取得NotificationManagerCompat的實體
notificationManagerCompat.notify(notificationId , notifcaition.build());
//填入辨識編號及notification後,即可發送出去
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment