我试图做,我想下一个头罩一切都会通知的通知的风格,他们将显示行明智。 如果一个新通知到来时,它应该是在第二最新的。 通知的名单应该是5,这意味着只有最新的5将会显示。
我用这下面的代码为这个,我不知道如何做到这一点,我想我的手StackBuilder太然而,我得到了,这会从更高的API比我现在用一个工作。
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(this, GcmActivity.class);
notificationIntent.putExtra("title", messagetype);
notificationIntent.putExtra("message", msg);
PendingIntent intent = PendingIntent.getActivity(this, 0,notificationIntent, 0);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("MY MESSENGER").setContentText("MESSAGES");
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle("MESSAGES" + " Details");
inboxStyle.addLine(messagetype + ":" + msg);
mBuilder.setStyle(inboxStyle);
mBuilder.setContentIntent(intent);
mBuilder.setAutoCancel(true);
notificationManager.notify(Integer.parseInt("0"), mBuilder.build());
我知道我可以通过添加任意数量的行做到这一点,同时创造
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
不过,我想,当我过会GCMIntentService被调用,这个名单将被更新。
我尝试使用这个下面的代码以及但是,这种没有任何工作的工作
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(this, GcmActivity.class);
notificationIntent.putExtra("title", messagetype);
notificationIntent.putExtra("message", msg);
PendingIntent intent = PendingIntent.getActivity(this, 0,notificationIntent, 0);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setAutoCancel(true)
.setContentTitle("MY MESSENGER")
.setSmallIcon(R.drawable.ic_launcher)
.setContentText("MESSAGES");
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
for(int j= 0; j<listMessage.size(); j++)
inboxStyle.addLine(listMessage.get(j));
mBuilder.setStyle(inboxStyle);
mBuilder.setContentIntent(intent);
notificationManager.notify(0, mBuilder.build());