【问题标题】:Android: How to Get location updates in backgroundAndroid:如何在后台获取位置更新
【发布时间】:2019-03-18 07:45:00
【问题描述】:

我在onStartCommand() 中使用fusedLocationProviderClient.requestLocationUpdates() 请求位置更新。它工作正常。但是当我关闭应用程序或终止应用程序时,onLocationResult() 不会被调用。

【问题讨论】:

标签: android service background location


【解决方案1】:

您需要使用 ForegroundService。以下是完全按照您的意愿行事的完整代码:

https://github.com/googlesamples/android-play-location/tree/master/LocationUpdatesForegroundService

【讨论】:

    猜你喜欢
    • 2020-03-12
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-17
    • 1970-01-01
    相关资源
    最近更新 更多