I have an app that, when a certain activity starts, needs to fill in one field with the current address. I'm not sure the way I'm doing it ever updates the gps coordinates unless another app, that uses gps, is started.
I can get the address with the Geocoder if I have a location. And I can get the location with the getLastLocation
of the Google Locations API.
If I follow the tutorial steps and initialize the api in onCreate
like this:
GoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(LocationServices.API).build();
and in onConnect
get the last location like this:
Location lastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
I get the feeling that I'm only getting the last known address but this above code doesn't actually start the GPS on the phone.
Do I need to enable location updates in onConnected
and then the first time I get the location I turn of the updates or will the above code actually start the GPS?