title: Alarm Manager not working when app closed
body: <p>I've been stuck on this for days now.
  I want my alarm manager to fire off every 15 minutes even when the app is closed but it does not work when app is closed. It works while app is open though.</p>
  
  <p>In my manifest file I have: </p>
  
  <pre><code>  &lt;!-- Used to consume the alarm manager alerts when app clsoed --&gt;
      &lt;receiver
         android:name="biz.customName.pkg.AlarmReceiver"
          android:enabled="true"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="biz.customName.pkg.msg"/&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>My BroadcastReceiver class (AlarmReceiver)</p>
  
  <pre><code>public class AlarmReceiver extends BroadcastReceiver
  {
  
  // Alarm manager used to run install when app is closed
  AlarmManager alarmManager;
  
  
  // Called when alarm received
  @Override
  public void onReceive(Context context, Intent intent)
  {
  
      // Enable alarm
      setupAlarm(context);
  
      // Perform background task 
  }
  
  
  // Setup alarm
  public void setupAlarm(Context context)
  {
      // Setup reciever for alarm
    //  context.registerReceiver(this, new IntentFilter("biz.customName.pkg.msg"));
  
      // Setup pending intent
      PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(Loader.filterName), PendingIntent.FLAG_UPDATE_CURRENT);
  
      // Setup alarm
      alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
  
      final long triggerTime = System.currentTimeMillis() + 900 * 1000;
  
      // Newest OS
      if (Build.VERSION.SDK_INT &gt;= 19 &amp;&amp; Build.VERSION.SDK_INT &lt; 23)
      {
          alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerTime, pendingIntent);
      }
   }
  }
  </code></pre>
  
  <p>In main I call setup alarm to get the alarm going initially then each time the onReceive inside my Broadcast receiver is called I reset the alarm.</p>
  
  <p>What am I doing wrong that it doesn't work when the app is closed?</p>