Search code examples
androidandroid-intentbroadcastreceiveralarm

Android O Register for Alarm Clock Intent


I've developed an application that triggers an action when the alarm rings. To implement this behavior I registered a BroadcastReceiver with various Intent-Filter definitions for different manufacterer alarms.

Since the restrictions of Android-O I'm no longer able to receive the Intents from the different alarms.

I tried to register the Intent via code:

registerBroadcast

That works to catch intents as long as the application is runnnig. When the application is killed the BroadcastReceiver does no longer receive any intents.

Is there any possible Solution to trigger an action when a alarm rings in Android-O ? Also a different solution as using a BroadcasReceiver would be appreciated.

I took a look at JobIntentService, explicit and implicit Broadcasts, but I think I don't get it how to implement a possible solution in Android-O.


Solution

  • I've developed an application that triggers an action when the alarm rings.

    That is not possible in general.

    To implement this behavior I registered a BroadcastReceiver with various Intent-Filter definitions for different manufacterer alarms.

    This will not work for the vast majority of alarm clock apps. There is no requirement for an alarm clock app to tell other apps that an alarm has gone off.

    Is there any possible Solution to trigger an action when a alarm rings in Android-O ?

    There is no solution for this on any version of Android. Again: there is no requirement for an alarm clock app to tell other apps that an alarm has gone off.

    With regards to trying to getting your limited existing implementation to work... you already took the one option: have a service running. This would have to be a foreground service, given other Android 8.0+ restrictions. And, as you note, this only works while the service is running.