title: Broadcast not delivered when App is not in the foreground/recent list
body: <p>Following is what happens:</p>
  
  <ul>
  <li>I have registered a network state change listener.</li>
  <li><p>When the control comes into it on network state change, I create an Alarm for 5 minutes later, to show a notification:</p>
  
  <pre><code>Intent alarmIntent = new Intent(context, NotificationReceiver.class);
  alarmIntent.putExtra(EXTRA_MODE, MODE);
  
  alarmIntent.setAction(NotificationReceiver.INTENT_ACTION);
  PendingIntent pendingIntent = PendingIntent.getBroadcast(context, requestCode, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
  manager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + delay, pendingIntent);
  </code></pre></li>
  </ul>
  
  <p>here <code>delay</code> = 5000</p>
  
  <ul>
  <li>Then in NotificationReceiver, I show a notification</li>
  <li>I have defined the notification receiver in manifest like this: <a href="https://gist.github.com/Sheikh-Aman/ee40ec35c52ed9d66d6d" rel="nofollow">https://gist.github.com/Sheikh-Aman/ee40ec35c52ed9d66d6d</a>
  (it wasn't appearing here don't know why)</li>
  </ul>
  
  <p>Now when the network state changes, I do get a notification and I am able to set the Alarm.
  When the alarm goes off, I don't receive the control in <code>onReceive</code> of <code>NotificationReceiver</code> most of the times, mainly when the app is not in the foreground and not in the recent task list.</p>
  
  <p>Any idea why that would be happening or what am I doing wrong here?</p>
  
  <p><strong>UPDATE:</strong> I am able to reproduce it on a Nexus 5, running 5.x<br>
  This is how it is reproduced:</p>
  
  <ul>
  <li>Install the app</li>
  <li>Don't open it</li>
  <li>Change network state and receive no notification</li>
  </ul>
  
  <p>Is it because the app has to be started at least once for it's alarms and broadcast receivers to work?</p>
  
  <p><strong>FINAL UPDATE:</strong> : Turns out that unless the app is started at least once after install, it remains in the <code>Stopped</code> state, which is equivalent to Force Closing an app from settings, and in this state, no broadcasts are delivered. This means I hit a platform limitation in this case.</p>