title: Android: AlarmManager sometimes doesn't call BroadcastReceiver
body: <p>In my app, I've got a <code>BroadcastReceiver</code>, which is called by an <code>AlarmManager</code>. That <code>BroadcastReceiver</code> calls CommonsWare's <code>WakefulIntentservice</code>.</p>
  
  <p>I tested this on my phone, and it appeared that sometimes, my <code>BroadcastReceiver</code> isn't called at all. I'm really confused about what it could be. My BroadcastReceiver and WakefulIntentservice are registerd in the manifest.</p>
  
  <p>This is my code:
  In AlarmActivity:</p>
  
  <pre><code>Calendar cal = Calendar.getInstance();
  cal.add(Calendar.SECOND, 2);
  
  Intent intent = new Intent(this, AlarmReceiver.class);
  PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
  
  AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
  alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), savedIntervalAutomaticMilisInt, pendingIntent);
  
  Toast.makeText(this, "Saved", Toast.LENGTH_LONG).show();
  
  finish();
  </code></pre>
  
  <p>AlarmReceiver:</p>
  
  <pre><code>package com.something.app;
  
  import com.commonsware.cwac.wakeful.WakefulIntentService;
  
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  
  public class AlarmReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          Intent i = new Intent(context, AlarmService.class);
          WakefulIntentService.sendWakefulWork(context, i);
      }
  }
  </code></pre>
  
  <p>And AlarmService:</p>
  
  <pre><code>package com.something.app;
  
  import android.app.PendingIntent;
  import android.content.Intent;
  import com.commonsware.cwac.wakeful.WakefulIntentService;
  
  public class AlarmService extends WakefulIntentService {
  
      public AlarmService() {
          super("AlarmService");
      }
  
      @Override
      protected void doWakefulWork(Intent arg0) {
          //A looooooooot of stuff
      }
  </code></pre>
  
  <p>Does anyone know why the <code>BroadcastReceiver</code> sometimes isn't called?</p>
  
  <p>EDIT: I heard about setting a <code>BroadcastReceiver</code> which receives <code>onBootCompleted</code>. Is that required?</p>