1

I am using alarm manager to display multiple local notification. The notification works fine, but the sequence of notification is happens only after i clear it from notification bar. The sequence is not happened.

code to pending 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...");

Code to display notification

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

How to do multiple notification sequence without clearing the existing message from notification. Thanks in advance

4

2 回答 2

3

使用这行代码

nm.notify( System.currentTimeMillis(), notif);

您已将其设置为 1,因此每次它都会覆盖通知

于 2013-08-14T06:03:55.097 回答
1

您总是在意图中传递相同的请求代码。所以只需要更改请求代码。

 PendingIntent contentIntent = PendingIntent.getActivity(context, request_code,  new Intent(), 0);

还需要更改通知ID。

nm.notify(change_notify_id, notif);
于 2013-08-14T06:06:12.180 回答