Geofence transition PendingIntent blocked by the OS on Android Oreo

久未见 提交于 2019-12-02 21:30:30

This is caused by the new Android Oreo background service limitations.

You have to change the PendingIntent from using a Service to using a BroadcastReceiver.

See this CodeLab for further information and example code.

In addition to switching to a BroadcastReceiver as mentioned in the accepted answer, I'd like to point out that although you will still receive BOOT_COMPLETED, you will not be able to receive PROVIDERS_CHANGED any longer.

PROVIDERS_CHANGED is an implicit broadcast and is not in the list of broadcast exceptions.

BOOT_COMPLETED is in the list of broadcast exceptions which is why you'll still receive it.

If you want to learn about an alternative approach to get the hook when location services is toggled, please see my answer to a related question for more details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!