Since O is more enforcing background services, how can I receive a broadcast of USER_PRESENT when targeting 26+ ?
Logcat :
system_process W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.USER_PRESENT flg=0x24200010 } to fr.cab13140.nullcontactdeleter/.BootThread
The Android system automatically sends broadcasts when various system events occur, such as when the system switches in and out of airplane mode. The system sends these broadcasts to all apps that are subscribed to receive the event.
An intent is a messaging object, a broadcast receiver is an app component. An intent is used to request some action from some app component, it could be a broadcast receiver, an activity or a service.
There are two types of broadcast receivers: Static receivers, which you register in the Android manifest file. Dynamic receivers, which you register using a context.
The only way to receive that broadcast is by having a running process, where you have used registerReceiver()
to register your receiver. If you are trying to listen to this broadcast all of the time, the closest that you will get will be to have a foreground sticky service, to try to maximize the amount of time your service is running. Note that users may not appreciate this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With