我正在使用警报管理器显示多个本地通知。通知工作正常,但通知的顺序只有在我从通知栏中清除它后才会发生。序列没有发生。
未决 Intent 代码
Intent intent = new Intent(this, TimeAlarm.class);
for(int i=0;i<milliSec.size();i++){
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,intent, PendingIntent.FLAG_ONE_SHOT);
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),(milliSec.get(i)), pendingIntent);
System.out.println("Calling Alaram...");
显示通知的代码
public void onReceive(Context context, Intent intent) {
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence from = "Sample Notification";
CharSequence message = "Notification different milliseconds ...";
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
Notification notif = new Notification(R.drawable.ic_launcher, "Notification Test...", System.currentTimeMillis());
notif.setLatestEventInfo(context, from, message, contentIntent);
notif.flags= Notification.FLAG_AUTO_CANCEL;
nm.notify(1, notif);
}
如何在不从通知中清除现有消息的情况下执行多个通知序列。提前致谢
最佳答案
使用这行代码
nm.notify( System.currentTimeMillis(), notif);
您已将其设置为 1,因此每次它都会覆盖通知
关于android - 多重通知--android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18224235/