从documenation中的NotificationManager
Android中:
公共无效通知(INT ID,通知通知)发布通知在状态栏显示。 如果具有相同ID的通知已经发布您的应用程序并没有被取消,它会被更新的信息所替代。
it will be replaced by the updated information.
我不想被替换的旧信息,我想这两个通知。 注:每个通知都有自己的ID:
notificationManager.notify(0, notification);
notificationManager.notify(1, notification);
这个怎么做?
栈您的通知
如果您的应用程序创建而另一个同类型的仍悬而未决的通知,避免创建一种全新的通知对象。 相反,可堆叠通知。
堆叠通知建立了一个总结性描述,并允许用户了解如何在特定种类的许多通知正在申请中。
http://developer.android.com/design/patterns/notifications.html
公共无效通知(字符串标记,INT ID,通知通告)
自:API级别5发布通知,在状态栏中显示。 如果用相同的标签和标识的通知已经发布您的应用程序并没有被取消,它会被更新的信息所替代。
参数标记此通知的字符串标识符。 可以为空。 ID此通知的标识符。 对(标签ID)必须是你的应用程序中是唯一的。 通知说明什么来显示用户的通知对象。 不能为null。
试试这个:
private void notifyMe(String message) {
NotificationManager nManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationCompat.Builder ncomp = new NotificationCompat.Builder(this);
ncomp.setContentTitle(getResources().getString(R.string.notification_title));
ncomp.setContentText(message);
ncomp.setTicker(getResources().getString(R.string.notification_ticker));
ncomp.setSmallIcon(R.drawable.ic_launcher);
ncomp.setAutoCancel(true);
//nManager.notify((int) System.currentTimeMillis(), ncomp.build());
nManager.notify(int(System.currentTimemillisec
), ncomp.build());
}