Skip to content

Instantly share code, notes, and snippets.

@ngima
Created July 2, 2018 08:08
Show Gist options
  • Save ngima/a882f85858b90c6a20578fde993225d0 to your computer and use it in GitHub Desktop.
Save ngima/a882f85858b90c6a20578fde993225d0 to your computer and use it in GitHub Desktop.
private fun displayLocationSettingsRequest(context: Context) {
var googleApiClient = GoogleApiClient.Builder(context)
.addApi(LocationServices.API).build();
googleApiClient.connect();
var locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(30 * 1000);
locationRequest.setFastestInterval(5 * 1000);
var builder = LocationSettingsRequest.Builder()
.addLocationRequest(locationRequest);
builder.setAlwaysShow(true);
var result = LocationServices.getSettingsClient(context).checkLocationSettings(builder.build());
result.addOnCompleteListener {
when(it.isSuccessful){
true->{}
false->{}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment