title: AlarmManager deleted - force close app
body: <p>I'm looking for a solution for days now. There might not even be a solution.</p>
  
  <p>What happens is the following:
  I got an application which schedules alarms for users, for the user to get out of bed. It's really important that the alarms "always" go off.</p>
  
  <p>To be able to let the alarms go off I make use of an AlarmManager. This schedules intents to be executed on scheduled times. This works fine when the Application is open or closed with the back/home button.</p>
  
  <p>When I close the app with Force Close option, the Alarm Manager alarms get cleared from the system and they will not go off.</p>
  
  <p>I have tried the following things already:</p>
  
  <ul>
  <li>START_STICKY Service</li>
  <li>DefaultUncaughtExceptionHandler - Won't work, because there isn't an exception caught for force closing the app.</li>
  <li>Broadcast Receiver - The issue is with the alarms being deleted.</li>
  </ul>
  
  <p>I'm wondering if anyone has experienced the same issue with the AlarmManager class and if you found a solution or alternative to fix this problem.</p>
  
  <p>p.s. I'm creating the Alarm Manager alarms like this:</p>
  
  <pre><code>            Intent myIntent = new Intent(getApplicationContext(), CheckAlarmService.class);
  
              PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(),
              1, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
              AlarmManager alarmManager = (AlarmManager)getApplicationContext().getSystemService(ALARM_SERVICE);
  
              Calendar calendar = Calendar.getInstance();
  
              int daysTillAlarm = AlarmHelper.calculateDaysTillAlarm(alarm);
              calendar.add(Calendar.DATE, 0);
              calendar.set(Calendar.HOUR_OF_DAY, 15);
              calendar.set(Calendar.MINUTE, 0);
              calendar.set(Calendar.SECOND, 0);
  
              alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>To try and see if I wasn't the only one with the issue, I downloaded some well used alarm clocks. They all seem to have the same behavior as I do. For now I'll leave it be. They're also well rated. </p>
  
  <p>Still if you might have the solution to this problem I'd like to know!</p>