FusedLocation API - onLocationChanged not being called
In our application, the flow looks like this:
- show a full screen activity explaining to the user why we need a GPS location
- get GPS permission
- displays loading readings
- get the first geolocation
- send first location to server
- download the relevant data from the server
- hide spinner loading
we have had several support requests from users saying nothing is happening and that they only see the bootloader.
We are currently activating activated GPS providers, so this is not a problem with inactive services.
I was able to reproduce the error by creating a user account on one of our phones and running the app, and I noticed that onLocationChanged was not called
The code passes by LocationServices.FusedLocationApi.requestLocationUpdates
, so it should provide locations, but not
I know I have solved this problem in the past by opening google maps, but
a) I can't imagine users haven't used google maps yet b) tell them to open google maps to fix a problem in our app sounds weird
here is the gist of the exact code used (I set a breakpoint on line 131, started debugging and got there, so I must be getting the locations, but the onLocationChanged method is never called
source to share
the "solution", if you want to call it, was to tell users to open google maps, hit the find me button, wait for google maps to find them, and then reopen our app and tell us, did something
edit:
Better yet, refactor everything to avoid using google-api-client at all, which would look something like this:
link (this is kotlin, whatever, kotlin is nice)
edit 2: I changed it from the eventbus implementation instead of rx-subject. eventbuses are really messy and you should stay away from them if possible.
source to share