OnLocationChanged callback is never called

前端 未结 14 1319
星月不相逢
星月不相逢 2020-12-01 03:28

I am trying to get the users current location using the LocationManager. I have done a lot of research and can\'t seem to find anyone with the same problem. T

相关标签:
14条回答
  • 2020-12-01 04:07

    GPS Provider will disable when device in low power or use power save mode then in that case we can not receive onLocationChanged

    GPS Provider hardly ever return the location if you stay inside house or building (only work well in outdoor)

    Therefore, in my app I will use both GPS_PROVIDER and NETWORK_PROVIDER to receive onLocationChanged() better

    https://developer.android.com/guide/topics/location/strategies.html#Updates

    To request location updates from the GPS provider, use GPS_PROVIDER instead of NETWORK_PROVIDER. You can also request location updates from both the GPS and the Network Location Provider by calling requestLocationUpdates() twice—once for NETWORK_PROVIDER and once for GPS_PROVIDER.

    0 讨论(0)
  • 2020-12-01 04:07

    I experienced similar issue. I had the permissions, requested for service correctly, but no update came. It turned out that all I had to do was simply wait. While I was searching for the issue on the internet, I had the application running and after few minutes it just started to receiving updates. Then even when I killed the app and run it again, the updates came instantaneously - I guess it is a system thing, some optimization, maybe due to the fact that device wasn't moving at all (btw. it is not some shitty device, it is Pixel).

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