2014-03-24 46 views
1

我嘗試一個通知示例。如何添加Android Notificaton其他說明?

如何添加額外的指令這樣的形象

enter image description here

我的通知代碼

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) 
     .setContentTitle("New Message with implicit intent") 
     .setContentText("New message from javacodegeeks received...") 
     .setTicker("Implicit: New Message Received!") 
     .setSmallIcon(MainActivity.NotiImage) 
     .setAutoCancel(false) 
     .setNumber(++NotificationHelper.messagges) 
     .setLargeIcon(BitmapFactory.decodeResource(getResources(), MainActivity.NotiImage)); 

     NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); 

     String[] events = new String[3]; 
     events[0] = new String("1) Message for implicit intent"); 
     events[1] = new String("2) big view Notification"); 
     events[2] = new String("3) from javacodegeeks!"); 

     inboxStyle.setBigContentTitle("More Details:"); 
     for (int i=0; i < 9; i++) { 
      inboxStyle.addLine("olkun " + i); 
     } 
     mBuilder.setStyle(inboxStyle); 
     NotificationManager myNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
     myNotificationManager.notify(1, mBuilder.build()); 

回答

0

,你將不得不使用「大畫面風格」像這樣

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) 
.setSmallIcon(R.drawable.notification_icon) 
.setContentTitle("Event tracker") 
.setContentText("Events received") 
NotificationCompat.InboxStyle inboxStyle = 
    new NotificationCompat.InboxStyle(); 
String[] events = new String[6]; 
// Sets a title for the Inbox style big view 
inboxStyle.setBigContentTitle("Event tracker details:"); 
... 
// Moves events into the big view 
for (int i=0; i < events.length; i++) { 

inboxStyle.addLine(events[i]); 
} 
// Moves the big view style object into the notification object. 
mBuilder.setStyle(inBoxStyle); 
... 
// Issue the notification here. 

事件寫入陣列