OnLocationChanged callback is never called

前端 未结 14 1421
星月不相逢
星月不相逢 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:05

    I have 2 devices: Samsung Galaxy S4 (Android 5.0.1) and Vertex Win (Android 8.1).

    On Samsung everything works right and fast, GPS coordinates are found, and onLocationChanged is called.

    On Vertex in prioity PRIORITY_BALANCED_POWER_ACCURACY it probably interacts with network provider first, so it finds coordinates via Wi-Fi. But it can't detect right, whether location service is turned on (after some time the device thinks it is turned on, while it is off, and calls addOnSuccessListener method of LocationServices.getSettingsClient. So I switched to PRIORITY_HIGH_ACCURACY and got another surprise. Network provider turned off, but onLocationChanged wasn't called, so I couldn't get coordinates. I downloaded GPS tester (as @Li3ro advised) from Play Market and saw that sattelites are visible, but without fixed signal. I couldn't receive a signal inside a building.

    Even standalone maps couldn't receive coordinates, but outdoor could. So, after I walked away, I could find my coordindinates in an application.

    See also https://stackoverflow.com/a/27828929/2914140, where it is said about priorities and error recognition (disabling GPS after some time if no coordinsates found).

提交回复
热议问题