I have read the Android documentation regarding the new background restrictions in Android API Level 26, and with those in mind, I have designed my app as follows:
- The app has a
BroadcastReceiver
listening for the"SMS_RECEIVED"
broadcast. This is an implicit broadcast, which are now restricted in Oreo, however it is one of those in their exceptions list. - When this
BroadcastReceiver
runs, it enqueues a new task to be performed by aJobIntentService
. When receiving the broadcast, the app should be temporarily whitelisted and therefore, theJobIntentService
given a window of opportunity to do its thing.
All of this seems to be working just fine, even if I close the app from the "recent apps" list. However, I'm getting reports from some users that apparently every few days, they have to open the app again because it suddenly stops working in the background.
Why does the OS suddenly stop sending the "SMS_RECEIVED"
broadcast to my app? If it is not that, then it must be the JobIntentService
not being allowed to run. Why not? The app should be whitelisted immediately after receiving the SMS. What am I misunderstanding?