title: Receive callback from AlarmManager while screen is locked
body: <p>I am using the Android AlarmManager to receive events at a specific time. </p>
  
  <pre><code>    alarm_manager = (AlarmManager)getSystemService(ALARM_SERVICE);
      alarm_manager.set(AlarmManager.RTC_WAKEUP, target_time, pending_intent);
  </code></pre>
  
  <p>The pending intent is created like this:</p>
  
  <pre><code>    pending_intent = createPendingResult(PENDING_INTENT_ID, new Intent(), 0);
  </code></pre>
  
  <p>In order to make the alarm trigger while the phone is off, I acquire a partial wakelock:</p>
  
  <pre><code>    power_manager = (PowerManager)getSystemService(POWER_SERVICE);
      wake_lock = power_manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getString(R.string.app_name));
      wake_lock.acquire();
  </code></pre>
  
  <p>Events are handled in the onActivityResult callback:</p>
  
  <pre><code>    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  </code></pre>
  
  <p>My problem is that if I start the activity, then press the power button on my phone (which turns the screen off + locks it), the event will not be delivered until the user turns on the phone again, and unlocks the screen.</p>
  
  <p>I assume it has something to do with the lock screen (maybe because the screen is locked, android figures the intent won't do anything anyway?) - but I find little to no information to my problem. With the partial wake lock, I would expect onActivityResult to be called, no matter if I turned off the screen, or whether it's locked - but obviously that's not the case.</p>
  
  <p>Can anyone point me as to where I'm wrong?</p>