2 momo1199 Momo1199 于 2013.08.14 15:17 提问

android-批量通知顺序

使用alarm manager批量显示本地通知。但是只有在清除通知条后才能让通知按顺序进行。

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);
    }

如果不清除当前信息,怎么顺序显示通知?

1个回答

Chengzi_963
Chengzi_963   2013.08.14 16:35
已采纳
nm.notify( System.currentTimeMillis(), notif);

需要设置为1。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!