title: Check if AlarmManager exists always returning false
body: <p>I want to show a daily notification with helping of <code>AlarmManager</code>.</p>
  
  <p>It was working properly until I tried to make it persistent after reboot </p>
  
  <p>I create the Alarm as follows:</p>
  
  <pre><code>if (switch_notif.isChecked()){ //in my activity's code
      NotificationReceiver.scheduleAlarms(getApplicationContext()); //allow the notification
  
  } else {
      NotificationReceiver.stopNotif(getApplicationContext()); //disable them
  }
  </code></pre>
  
  <p>Here is my broadcast receiver:</p>
  
  <pre><code>public class NotificationReceiver extends BroadcastReceiver{
  
      @Override
      public void onReceive(Context context, Intent intent) {
  
          //Log.d("NotificationReceiver", "onReceive");
          this.sendNotif(context);
  
          //trying to see if there is already an alarm in place (for reboot)
          boolean alarmUp = (PendingIntent.getBroadcast(context, 100,
                  new Intent(),
                  PendingIntent.FLAG_NO_CREATE) != null);
          Log.d("NotificationReceiver", alarmUp? "true":"false" ); //always return false
  
          if (alarmUp)
          {
              //Log.d("NotificationReceiver", "Alarm is already active");
          }
          else { //if no alarm, schedule one
              //Log.d("NotificationReceiver", "Alarm is not active");
              this.scheduleAlarms(context); 
  
          }
      }
  
      public static void scheduleAlarms(Context context) {
  
          //Log.d("NotificationReceiver", "scheduleAlarms");
          Calendar alarmStartTime = Calendar.getInstance();
          Calendar now = Calendar.getInstance();
          alarmStartTime.set(Calendar.HOUR_OF_DAY, 13);
          alarmStartTime.set(Calendar.MINUTE, 31);
          alarmStartTime.set(Calendar.SECOND, 30);
          /*if (now.after(alarmStartTime)) { // not needed when using 1min repeat for testing
              Log.d("Alarm","Added a day");
              alarmStartTime.add(Calendar.DATE, 1);
          }*/
  
          Intent intent = new Intent(context, NotificationReceiver.class);
  
          PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 100, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  
          AlarmManager alarmManager = (AlarmManager) context.getSystemService(context.ALARM_SERVICE);
          alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,alarmStartTime.getTimeInMillis(),60000 ,pendingIntent); // set to 1minute for testing purpose
  
      }
  
      public static void sendNotif(Context context){ //fire the notification
  
          //Log.d("NotificationReceiver", "sendNotif");
          NotificationManager notificationManager = (NotificationManager) context.getSystemService(
                  Context.NOTIFICATION_SERVICE);
  
          Intent intent1 = new Intent(context, Notification.class);
          intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  
          PendingIntent pendingIntent = PendingIntent.getActivity(
                  context, 100, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
  
          Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
  
          NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                  .setContentIntent(pendingIntent)
                  .setSmallIcon(R.drawable.ic_notif)
                  .setContentTitle("Rappel MyCardioPad")
                  .setContentText("Vous avez une séance d'éffort aujourd'hui")
                  .setSound(soundUri)
                  .setAutoCancel(true);
  
          notificationManager.notify(100, builder.build());
  
      }
  
      public static void stopNotif(Context context){ //Allow to turn off the alarm/notification
  
          //Log.d("NotificationReceiver", "stopNotif");
          Intent intent = new Intent(context, NotificationReceiver.class);
          PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 100, intent, PendingIntent.FLAG_UPDATE_CURRENT);
          AlarmManager alarmManager = (AlarmManager) context.getSystemService(context.ALARM_SERVICE);
          alarmManager.cancel(pendingIntent);
          pendingIntent.cancel();
      }
  }
  </code></pre>
  
  <p>edit:
  This is the log from when I turn off and turn on the alarm:</p>
  
  <pre><code>07-20 14:22:58.637 mycardiopad D/NotificationReceiver: scheduleAlarms
  07-20 14:22:59.856 mycardiopad D/NotificationReceiver: onReceive
  07-20 14:22:59.856 mycardiopad D/NotificationReceiver: sendNotif
  07-20 14:22:59.863 mycardiopad D/NotificationReceiver: false
  07-20 14:22:59.863 mycardiopad D/NotificationReceiver: Alarm is not active
  07-20 14:22:59.863 mycardiopad D/NotificationReceiver: scheduleAlarms
  07-20 14:22:59.908 mycardiopad D/NotificationReceiver: onReceive
  07-20 14:22:59.908 mycardiopad D/NotificationReceiver: sendNotif
  07-20 14:22:59.912 mycardiopad D/NotificationReceiver: false
  07-20 14:22:59.912 mycardiopad D/NotificationReceiver: Alarm is not active
  07-20 14:22:59.912 mycardiopad D/NotificationReceiver: scheduleAlarms
  07-20 14:23:00.509 mycardiopad D/NotificationReceiver: onReceive
  07-20 14:23:00.509 mycardiopad D/NotificationReceiver: sendNotif
  07-20 14:23:00.520 mycardiopad D/NotificationReceiver: false
  07-20 14:23:00.520 mycardiopad D/NotificationReceiver: Alarm is not active
  </code></pre>