0

After calling setMyLocationEnabled(true) on a GoogleMap, I see a blue dot indicating the user's current location. If I disable GPS and enable airplane mode, this blue dot remains visible on the map for 1-2 minutes before disappearing (and, naturally, the My Location button ceases to function).

I expected that I would be able to figure out when the dot disappeared by watching the onConnectionSuspended(int cause) callback that I specified when building the GoogleApiClient as described in the FusedLocationProviderApi documentation:

new GoogleApiClient.Builder(context)
    .addApi(LocationServices.API)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .build()

However, this callback does not seem to be invoked when I disable all location-providing components on my phone (thereby causing the blue dot to disappear). Is there a different callback I should be using to receive this information? If not, is rolling a custom LocationSource implementation a feasible/reasonable way to ensure my map UI can remain synced with other location-dependent UI in the rest of my app?

stkent
  • 19,772
  • 14
  • 85
  • 111
  • http://stackoverflow.com/questions/24804652/gpsstatus-switch-between-gps-event-started-and-gps-event-stopped/24812401#24812401 Been there had much better luck using a broadcastreceiver – danny117 Dec 03 '14 at 02:15
  • Thanks for the link. If my understanding is correct, that won't necessarily fire at the same time as the user location is actually removed from the map, right? Still, definitely a solution I'll think about. – stkent Dec 03 '14 at 02:27
  • the broadcastreceiver fires instantly when the gps is changed on or off. What you do with it is up to you. For example I just put a button on the map. You might turn off the location blue dot. – danny117 Dec 03 '14 at 02:53

0 Answers0