title: Cancel set notification permanently from application before gives notification alarm
body: <p>In my application when I delete reminder (reminder set for multiple event for same time),reminder alarm comes after one hour from the scheduled time.
  Is anybody facing same issue? Do anybody have solution for this.
  Below the code which I used in my application</p>
  
  <p>Notification Receiver page</p>
  
  <pre><code>public class NotificationReceiver extends BroadcastReceiver {
  
      //private static int NOTIFICATION_ID = 1;
      private static int NOTIFICATION_ID;
      @SuppressWarnings("deprecation")
      @Override
      public void onReceive(Context context, Intent intent) 
      {
          Bundle extras=intent.getExtras();
          NotificationManager manger = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
          Notification notification = new Notification(R.drawable.ic_launcher, "Combi Note",System.currentTimeMillis());
  
          NOTIFICATION_ID=Integer.parseInt(extras.getString("ID"));
          PendingIntent contentIntent = PendingIntent.getActivity(context,NOTIFICATION_ID,new Intent(context, NotificationReceiver.class), 0);
  
          String title=extras.getString("title");
          String note=extras.getString("note");
  
          notification.setLatestEventInfo(context, note, title, contentIntent);
          notification.flags = Notification.FLAG_INSISTENT;
          notification.defaults |= Notification.DEFAULT_SOUND;
          manger.notify(NOTIFICATION_ID, notification);
  
      }
  </code></pre>
  
  <p>For Notification Set Page</p>
  
  <p>In page, Button is used to set reminder</p>
  
  <pre><code>btnRemind.setOnClickListener(new OnClickListener() {
  
              public void onClick(View v) {
  
                   try
                      {
                       SimpleDateFormat curFormater = new SimpleDateFormat("dd/MM/yy hh:mm aa"); 
                       String s=StartTime;
  
                      //dateObj1 = curFormater.parse(StartTime); 
                      dateObj1 = curFormater.parse(StartTime);
                      //SimpleDateFormat postFormater = new SimpleDateFormat("dd/MM/yy H:mm:ss.SSS"); 
                      SimpleDateFormat postFormater = new SimpleDateFormat("dd/MM/yy H:mm");
                      Date date2 = postFormater.parse(postFormater.format(dateObj1));
  
                      Calendar cl=Calendar.getInstance();
                      cl.setTime(date2);
  
                      MONTH=cl.get(Calendar.MONTH);
                      YEAR=cl.get(Calendar.YEAR);
                      DAY=cl.get(Calendar.DAY_OF_MONTH);
                      HOUR=cl.get(Calendar.HOUR_OF_DAY);
                      if(cl.get(Calendar.MINUTE)&gt;5)
                            cl.add(Calendar.MINUTE, -5);
                      else
                      {
                           cl.add(Calendar.HOUR, -1);
                           cl.add(Calendar.MINUTE, -5);
                      }
                      MINUTE=cl.get(Calendar.MINUTE);
  
                      }
                      catch (Exception e) 
                      {
                          e.printStackTrace();    
                      }               
  
                  Calendar cal=Calendar.getInstance();
  
                  cal.set(Calendar.MONTH, MONTH);
                  cal.set(Calendar.YEAR, YEAR);               
                  cal.set(Calendar.DAY_OF_MONTH, DAY);
                  cal.set(Calendar.HOUR_OF_DAY, HOUR);
                  cal.set(Calendar.MINUTE, MINUTE);
  
                  Intent alarmintent = new Intent(getApplicationContext(), NotificationReceiver.class);
                  alarmintent.putExtra("note",txtEvent.getText()+" starts in 5 minutes on channel " +Channel);
                  boolean chkReminder=new DatabaseHelper(getApplicationContext()).checkReminders(Channel+" : "+txtEvent.getText().toString(), dateObj1);
                  if(chkReminder)
                  {
                      Toast.makeText(getApplicationContext(), "Reminder is already Set for this event !!", Toast.LENGTH_LONG).show();
                  }
                  else
                  {
                      //new DatabaseHelper(getApplicationContext()).addReminder(Channel+" : "+txtEvent.getText().toString(), dateObj1);
                      int ID = Integer.parseInt(strEventID);
                      new DatabaseHelper(getApplicationContext()).addReminder(String.valueOf(ID), Channel+" : "+txtEvent.getText().toString(), dateObj1);
                      //Random r = new Random();
                      //int ID = r.nextInt();
                      alarmintent.putExtra("ID", strEventID);
                      PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(),ID,alarmintent,PendingIntent.FLAG_UPDATE_CURRENT|  Intent.FILL_IN_DATA);
  
                      AlarmManager am = (AlarmManager) getApplicationContext().getSystemService("alarm");
                      am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);
                      Toast.makeText(getApplicationContext(), "Reminder Set !!", Toast.LENGTH_LONG).show();
                      //btnRemind.setVisibility(View.INVISIBLE);
                  }
              }
          });
  
      }
  </code></pre>
  
  <p>for delete reminder before it raised i used:</p>
  
  <pre><code>private void checkButtonClick() 
      {
          ImageButton btnDelete=(ImageButton) findViewById(R.id.imgbtnDelete);
          btnDelete.setOnClickListener(new OnClickListener() 
          {
  
                      public void onClick(View v) 
                      {
  
                          StringBuffer responseText = new StringBuffer();
                          responseText.append("The following reminder is deleted from the list...\n");
                          String strRmDt="";
                          String strChannel="";
                          ArrayList&lt;States&gt; stateList = dataAdapter.stateList;
                          String strID="";
                          for(int i=0;i&lt;stateList.size();i++)
                          {
                               States state = stateList.get(i);
  
                              if(state.isSelected())
                              {
                                  try
                                  {
                                      //String reminder=stateList.get(i).toString();
                                      String reminder=state.name;
                                      String[] separated = reminder.split(" - ");
                                      String[] strSep2 = separated[0].toString().split(" :: ");
                                      new DatabaseHelper(getApplicationContext()).removeReminder(strSep2[0].toString());
                                      // delete notification alarm
                                      @SuppressWarnings("unused")
                                      SimpleDateFormat curFormater = new SimpleDateFormat("dd/MM/yy hh:mm aa"); 
  
                                      strRmDt=separated[1];
  
                                      //String stEvent=separated[0].toString();
                                      strID=strSep2[0].toString();
                                      int ID=Integer.parseInt(strID);
                                      Intent I = new Intent(getBaseContext(),NotificationReceiver.class);
                                      I.setAction(String.valueOf(ID));
                                      PendingIntent pIntent = PendingIntent.getBroadcast(getBaseContext(), ID, I, PendingIntent.FLAG_CANCEL_CURRENT);//.getBroadcast(getApplicationContext(), Integer.parseInt(strSep2[0].toString()), getIntent(), PendingIntent.FLAG_CANCEL_CURRENT);
                                      AlarmManager am = (AlarmManager) getApplicationContext().getSystemService("alarm");
                                      am.cancel(pIntent);
                                      pIntent.cancel();
                                      /*
                                      AlarmManager am = (AlarmManager) getSystemService(getApplicationContext().ALARM_SERVICE);
                                      Intent I = new Intent(getApplicationContext(),NotificationReceiver.class);
                                      PendingIntent P = PendingIntent.getBroadcast(getApplicationContext(), Integer.parseInt(strSep2[0].toString()), I, 0);
                                      am.cancel(P);
                                      P.cancel();
                                      */
                                      // end delete notification alarm
                                  }
                                  catch(Exception e) 
                                  {
                                      System.out.print(e.getMessage());
                                      e.printStackTrace();
                                  }   
                              }
  
                          }
                          Toast.makeText(getApplicationContext(),
                          responseText, Toast.LENGTH_LONG).show();
                          onRestart();
                      }
          });
  
          //RemindersListView.setAdapter(dataAdapter);
      }
  </code></pre>
  
  <p>Guys please help me</p>
  
  <p>Thanks in advance.</p>