title: Android 8.0 Oreo AlarmManager with broadcast receiver and implicit broadcast ban
body: <p>I have critical reminders that are set via the Alarm Manager (It should function the same way as an alarm clock application).</p>
  
  <p>Previously I had the following in my Android Manifest:</p>
  
  <pre><code>    &lt;receiver android:name="com.example.app.AlarmReceiver" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="${packageName}.alarm.action.trigger"/&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>The broadcast receiver:</p>
  
  <pre><code>public class AlarmReceiver extends BroadcastReceiver {
  
    @Override public void onReceive(
        final Context context,
        final Intent intent) {
  // WAKE LOCK
  // BUILD NOTIFICATION etc...
    }
  
  }
  </code></pre>
  
  <p>How the alarm is set:</p>
  
  <pre><code>final PendingIntent operation = PendingIntent.getBroadcast(
            mContext,
            requestCode,
            intent,
            PendingIntent.FLAG_CANCEL_CURRENT);
  
        if (PlatformUtils.hasMarshmallow()) {
          alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
  
        } else {
          alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
        }
  }
  </code></pre>
  
  <p>With Android 8.0 I can no longer use an implicit broadcast as defined in the Manifest. That's fine, the alternative given is to register it manually like so:</p>
  
  <pre><code>final BroadcastReceiver receiver = new AlarmReceiver();
  final IntentFilter intentFilter = new IntentFilter(ALARM_RECEIVER_INTENT_TRIGGER);
  context.registerReceiver(receiver, intentFilter);
  </code></pre>
  
  <p>This does not seem logical to me.</p>
  
  <ol>
  <li><p>The alarm receiver will be tied to the lifetime of the context. This causes an issue when say the application is killed due to memory pressure or when the device is restarted. I need my alarms to fire every time as they are critical for the health of the user.</p></li>
  <li><p>Even if I listen to <em>"android.intent.action.BOOT_COMPLETED"</em> and register my alarm receiver the app is killed shortly after and no alarm is fired. I also don't see my alarm via </p>
  
  <p>adb shell dumpsys alarm</p></li>
  </ol>
  
  <p>How do I create a custom broadcast receiver that receives an implicit broadcast to fire an alarm while targeting Android O (8.0)? Can someone enlighten me with a code example or link to documentation. How does Timely or any other alarm clock app function while targeting O?</p>