【发布时间】:2019-03-18 07:45:00
【问题描述】:
我在onStartCommand() 中使用fusedLocationProviderClient.requestLocationUpdates() 请求位置更新。它工作正常。但是当我关闭应用程序或终止应用程序时,onLocationResult() 不会被调用。
【问题讨论】:
标签: android service background location
我在onStartCommand() 中使用fusedLocationProviderClient.requestLocationUpdates() 请求位置更新。它工作正常。但是当我关闭应用程序或终止应用程序时,onLocationResult() 不会被调用。
【问题讨论】:
标签: android service background location
您需要使用 ForegroundService。以下是完全按照您的意愿行事的完整代码:
https://github.com/googlesamples/android-play-location/tree/master/LocationUpdatesForegroundService
【讨论】: