我有一个数据和我的应用程序,我想通过推通通知,因这里问题是我没有如何在状态栏。 在我的应用程序中,我从服务器收到 ArrayList的通知。 每个通知应该使用"通知生成器",在 which notify put notify notify,至少在状态栏( 一个带有 3个指示器的icon,而不是 3图标) 中显示 3消息,但我在打开状态栏时显示所有的消息。
我的代码有 :public void sendNotifications(ArrayList messages){
int notifyID = 0;
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
for(Message message:messages){
Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(),0, notificationIntent,
PendingIntent.FLAG_CANCEL_CURRENT);
Resources res = getApplicationContext().getResources();
Notification.Builder builder = new Notification.Builder(getApplicationContext());
builder.setContentIntent(contentIntent)
. setSmallIcon(R.drawable.ic_launcher)
. setLargeIcon(BitmapFactory.decodeResource(res, messages.media))
. setTicker("Got a new message")
. setWhen(System.currentTimeMillis())
. setAutoCancel(true)
. setContentTitle(message.titile)
. setContentText(message.text);
Notification notification = builder.getNotification();
mNotificationManager.notify(notifyID, notification);
notifyID++;
}
}
更新
为了了解更多的信息,我添加了图片
当我发送通知时 -pic1 - icon 显示了我有多少
当我打开状态栏时,-pic2会显示所有通知
这样做是有可能的?