Created
April 30, 2015 08:28
-
-
Save Aiur3908/fb40d8ff6518fa0cd8a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void sendNotification() { | |
int notificationId = 001; | |
//決定這個notification的辨識編號 | |
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); | |
inboxStyle.setBigContentTitle("InboxStyle") | |
.addLine("第一行") | |
.addLine("第二行") | |
.addLine("第三行") | |
.addLine("第四行") | |
.addLine("第五行") | |
.addLine("第六行") | |
.addLine("第七行") | |
.addLine("第八行") | |
.addLine("第九行") | |
.addLine("第十行"); | |
//創建InboxStyle物件,並使用addLine來增加想要顯示的內容 | |
NotificationCompat.Builder notifcaition = | |
new NotificationCompat.Builder(this) | |
.setSmallIcon(R.drawable.ic_launcher) | |
.setContentTitle("標題") | |
.setContentText("內容") | |
.setStyle(inboxStyle); | |
//最後在setStyle,將剛才的創建一個InboxStyle物件物件丟入即可 | |
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