Paso 10:
Ahora solo copiar y pegar siguiendo el código fuera método oncreate...
googleApiClient de GoogleApiClient privado;
Ahora solo copiar y pegar siguiendo el código en oncreate...
Si (googleApiClient == null) {}
googleApiClient = new GoogleApiClient.Builder(getApplicationContext()).addApi(LocationServices.API) .build(); googleApiClient.connect();
LocationRequest locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(30 * 1000); locationRequest.setFastestInterval(5 * 1000); LocationSettingsRequest.Builder constructor = nuevo .addLocationRequest(locationRequest) de LocationSettingsRequest.Builder();
// **************************
builder.setAlwaysShow(true); Este es el ingrediente clave
// **************************
PendingResult resultado = LocationServices.SettingsApi .checkLocationSettings (googleApiClient, builder.build()); result.setResultCallback (new ResultCallback)
{
público vacío onResult (LocationSettingsResult resultado)
{
estado final = result.getStatus();
Estado de LocationSettingsStates final = resultado .getLocationSettingsStates();
interruptor (status.getStatusCode())
{
caso LocationSettingsStatusCodes.SUCCESS:
rotura;
caso LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
trate de {}
status.startResolutionForResult (MainActivity.this, 1000);
} catch (IntentSender.SendIntentException e)
{
}
rotura;
caso LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
rotura;
}
});
}
googleApiClient = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();