title: Android AlarmManager BroadcastReceiver not working when user exits the application
body: <p>I'm having some problems with a BroadcastReceiver that is supposed to react on an AlarmManager notification. I've read several threads on this subject but coulnd't find anything that would help. I must be missing something.</p>
  
  <p>I set up the alarm the following way:</p>
  
  <pre><code>// Receiver intent
  Intent intent = new Intent(mContext, CalendarAlarmReceiver.class);
  intent.putExtra(CalendarAlarmReceiver.SHOW, show);
  // Sender
  PendingIntent sender = PendingIntent.getBroadcast(mContext, hashRequestCode(show), intent, PendingIntent.FLAG_UPDATE_CURRENT);
  mPendingAlarmRequests.put(show.getChannel() + show.getName() + show.getStart().toGMTString(), sender);
  // Get AlarmManager
  AlarmManager am = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
  am.set(AlarmManager.RTC_WAKEUP, show.getStart().getTime(), sender);
  </code></pre>
  
  <p>I created an CalendarAlarmReceiver class that extends BroadcastReceiver. In the onReceive() method I start a status bar notification that works fine if the application is running. However, if I exit the application by clicking the back button until it closes, the notifications no longer appear.</p>
  
  <p>I'm not sure if the receiver is called at all and it's just the notification that doesn't work or if the receiver is not called. </p>
  
  <p>It is registered in the manifest file:</p>
  
  <pre><code>&lt;receiver android:name=".calendar.CalendarAlarmReceiver" &gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>I read that this may not be the receiver's falut but rather the alarm may be cancelled when the application stops. If that is the case, is the solution to simply set the alarm in a service that is working all the time in the background?</p>