BroadcastReceiver Has No Internet Access
Solution 1:
CommonsWare put me in the right track.
The answer was the doze mode: android 6 and up can put the phone into a doze mode, in which apps won't receive internet access (among other things). So if you have set an alarm and a wake lock, you will get CPU access but no Internet access. The documentation says that if the device is plugged in it will not enter doze mode, but in my case it did enter despite the plug status:
From official documentation:
If a user leaves a device unplugged and stationary for a period of time, with the screen off, the device enters Doze mode.
That was confusing.
Any way, I tried whitelisting my app, and it started working just fine. Alarm goes off at 6am, and the broadcast receiver now has internet access.
Again from official documentation:
Users can manually configure the whitelist in Settings > Battery > Battery Optimization. Alternatively, the system provides ways for apps to ask users to whitelist them.
Hope I made myself clear, and that this helps someone else.
Thanks to CommonsWare.
Post a Comment for "BroadcastReceiver Has No Internet Access"