ste*_*neo 2 android google-play-services android-geofence google-location-services
这只发生在Android Oreo上.我正在使用Play Services 11.4.2.我正在使用GeofencingClient注册地理围栏,并将带有pendingIntent的addGeofences方法注册到处理地理围栏过渡的IntentService.看起来播放服务发送的意图在某些条件下被操作系统阻止.
系统记录以下内容:
Background start not allowed: service Intent { cmp=my.app.id/my.package.struct.GeofenceTransIntentService (has extras) } to my.app.id/my.package.struct.GeofenceTransIntentService from pid=-1 uid=10154 pkg=my.app.id
Run Code Online (Sandbox Code Playgroud)
一旦我在以下情况下添加地理围栏:
pin*_*ino 10
这是由新的Android Oreo后台服务限制引起的.
您必须将PendingIntent从使用服务更改为使用BroadcastReceiver.
有关更多信息和示例代码,请参阅此CodeLab.