Geofence transition PendingIntent blocked by the OS on Android Oreo

后端 未结 2 1039
鱼传尺愫
鱼传尺愫 2021-02-03 16:40

This only happens on Android Oreo. I\'m using Play Services 11.4.2. I\'m registering geofences using the GeofencingClient and the addGeofences method with a pendingIntent to an

相关标签:
2条回答
  • 2021-02-03 16:59

    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.

    0 讨论(0)
  • 2021-02-03 17:02

    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.

    0 讨论(0)
提交回复
热议问题