Новый PendingIntent обновляет текущее намерение

я пытаюсь показать разные уведомления через некоторый интервал времени, но происходит то, что он обновляет текущий PendingIntentновым, в результате я получаю только одно уведомление, даже если я запускаю 4–5 ожидающих запросы намерений

При нажатии кнопки я делаю следующее

 try{
                 adapter.OpenDB();
             int id = adapter.getMaxId("reminder")+1;
             adapter.CloseDB();
             Intent intent = new Intent(MilestonesActivity.this, AlarmReceiver.class);
             intent.putExtra("message", ""+editMsg.getText()+" "+editDate.getText());               
             intent.putExtra("id", id);
              PendingIntent pendingIntent = PendingIntent.getBroadcast(MilestonesActivity.this, 0,
                intent, PendingIntent.FLAG_UPDATE_CURRENT);
                am.set(AlarmManager.RTC_WAKEUP,
                reminddate.getTimeInMillis(), pendingIntent);

             adapter.CloseDB();
             }catch (Exception e) {
                // TODO: handle exception
            }

AlarmReceiver.java

 @Override
 public void onReceive(Context context, Intent intent) {

     Intent i =new Intent(context, NotificationService.class);

     try{

     int id = intent.getExtras().getInt("id");
        i.putExtra("id", id);
     CharSequence message = intent.getExtras().getString("message");
        i.putExtra("message", message);
     }catch (Exception e) {
        // TODO: handle exception
    }
     context.startService(i);

 }

NotificationService.java

 public void  show(Intent intent) {
 try{
        NotificationManager nm;
         Log.e("recieve", "ok");
      nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
      CharSequence from = "Lawyer app Reminder";
      CharSequence message = intent.getExtras().getString("message");
      PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 
                PendingIntent.FLAG_ONE_SHOT);// also tried FLAG_UPDATE_CURRENT
      int id =intent.getExtras().getInt("id");
      Log.e("I", ""+id);
      Notification notif = new Notification(R.drawable.message_active,
        "Lawyer app Reminder.", System.currentTimeMillis());
      notif.defaults = Notification.DEFAULT_ALL;
      notif.flags = Notification.FLAG_AUTO_CANCEL;

      notif.setLatestEventInfo(this, from, message, contentIntent);
      nm.notify(id, notif);

 }catch (Exception e) {         
     e.printStackTrace();            
}

пожалуйста, помогите мне с этим. заранее спасибо

8
задан Mahesh 14 March 2012 в 10:59
поделиться