lostzen / lost

A drop-in replacement for Google Play services location APIs for Android
http://mapzen.github.io/lost/
Other
352 stars 70 forks source link

No location update after reconnect (LOST 3.0.2) #233

Closed westnordost closed 7 years ago

westnordost commented 7 years ago

Description

After stopping location updates (through tabbing out / changing Activity) and disconnecting from LOST api client, when it is attempted to reconnect later and request location updates anew, onLocationChanged is never called.

Steps to Reproduce

For StreetComplete: Turn on location. Tab out or go to settings activity, then go back. The GPS button does not stop blinking (=app is waiting for a location update but does not get one).

Program flow:

  1. MainActivity.onStart(): locationRequestFragment.startRequest(); is called which ensures that the app has all the permissions and location is enabled. It then calls
  2. MainActivity.onLocationIsEnabled(): The GPS button is made to blink. singleLocationRequest.startRequest (source) connects to LOST, on connection requests location updates and then would, on receiving the first location update, make the GPS button stop blinking. The location update never comes.

Edit: Now after 5-10 minutes, the location update was received.

Lost & Android Version

LOST 3.0.2

westnordost commented 7 years ago

Additional information: With earlier versions (except the ones that crashed), a location update was available practically immediately when tabbing out and then in.

westnordost commented 7 years ago

(The revert is only for the stable v0.13. On master, LOST 3.0.2 is still used)

sarahsnow1 commented 7 years ago

The reason the initial location request is not received is because state is not cleared in the class which handles sending location updates when the service is shutdown. So, an initial location is attempted to be sent but is not deemed "good enough" and is therefore ignored.

https://github.com/mapzen/lost/blob/master/lost/src/main/java/com/mapzen/android/lost/internal/LostClientManager.java#L299-L304

Thanks for the report, I'll post a fix shortly.