Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FusedLocation API - onLocationChanged is not called

The flow in our app is the following:

  1. show a fullscreen activity explaining to the user why we need the GPS-location
  2. acquire the permission for GPS
  3. display loading spinner
  4. get first geolocation
  5. send first location to server
  6. load relevant data from server
  7. hide loading spinner

we've had multiple support requests from users saying that nothing happens and that they only see the loading spinner.

We're enforcing activated GPS-Providers at the moment, so it's not an issue of inactive locationservices.

I've managed to reproduce the bug by creating a user account on one of our phones and starting the app and I've noticed that onLocationChanged is not called

The code gets past LocationServices.FusedLocationApi.requestLocationUpdates, so it should provide locations, but it doesn't

I know that I solved this issue in the past by opening google maps, but

a) I can hardly imagine that users did not use google maps so far b) telling them to open google maps to fix an issue in our app sounds weird

here is a gist of the exact code used (I set a breakpoint on line 131, started to debug and got there, so I should be getting locations, but the method onLocationChanged is never called

like image 351
TormundThunderfist Avatar asked May 22 '17 06:05

TormundThunderfist


Video Answer


1 Answers

the "solution" if you want to call it that, was to tell users to open google maps, hit the "locate me" button, wait until google maps finds them and then open our app again and report back to us whether that did anything

edit:

even better, refactor the whole thing to not use a google-api-client at all, that would look something like this:

link (it's kotlin, whatever, kotlin is nice)

edit 2: I changed it from an eventbus implementation to an rx-subject instead. eventbuses are really dirty and if possible, you should stay away from them

like image 89
TormundThunderfist Avatar answered Sep 27 '22 22:09

TormundThunderfist