【发布时间】:2017-05-04 19:50:33
【问题描述】:
使用 PendingIntent.getService(...) 是请求位置更新的常用方法。这是否仍可用于在 O 设备上运行的应用以接收后台位置更新?
【问题讨论】:
标签: android android-location fusedlocationproviderapi android-fusedlocation
使用 PendingIntent.getService(...) 是请求位置更新的常用方法。这是否仍可用于在 O 设备上运行的应用以接收后台位置更新?
【问题讨论】:
标签: android android-location fusedlocationproviderapi android-fusedlocation
在调用 [FusedLocationPRviderApi#requestLocationUpdates](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderApi.html#requestLocationUpdates(com.google.android.gms.common.api.GoogleApiClient, com.google.android.gms.location. LocationRequest, android.app.PendingIntent))。
以 O 为目标的应用应仅使用 PendingIntent.getBroadcast()(并定义 BroadcastReceiver 并在清单中注册)以便在后台继续接收位置更新。这是因为面向 O 的应用是 subject to limits on services started in the background。
面向 O 的应用可以继续使用PendingIntent.getService(),如果它只需要在前台接收位置更新。
【讨论】: