stkent
stkent

Reputation: 20128

How can I be notified when Google Maps My Location layer loses user location?

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?

Upvotes: 0

Views: 139

Answers (0)

Related Questions