问题描述
- android-批量通知顺序
- 使用alarm manager批量显示本地通知。但是只有在清除通知条后才能让通知按顺序进行。
intent:
Intent intent = new Intent(this TimeAlarm.class); for(int i=0;i<milliSec.size();i++){ PendingIntent pendingIntent = PendingIntent.getBroadcast(this 0intent 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_launcherNotification 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。
时间: 2025-01-01 03:34:08