i'm using dialog from Location.Settings.Request and work it well in pre-lollipop, but in lollipop the wifi never starts only gps and bluetooth starts.
more detail:
when i choose yes button only gps y bluetooth starts, but the second time that call method detects wifi,gps,bletooth are active , and only gps y bluetooth but never wifi.
please help me i really i need implement in lollipop.
this is my method to show dialog:
This is my method to show dialog:
public void ActivarWifiGps(boolean gpsrequerido){
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API)
.build();
mGoogleApiClient.connect();
mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(FATEST_INTERVAL);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setSmallestDisplacement(10);
builder = new LocationSettingsRequest.Builder().addLocationRequest(mLocationRequest);
builder.setAlwaysShow(true);
builder.setNeedBle(true);
PendingResult<LocationSettingsResult> result =
LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
@Override
public void onResult(LocationSettingsResult result) {
final Status status = result.getStatus();
final LocationSettingsStates state = result.getLocationSettingsStates();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
// All location settings are satisfied. The client can initialize location
// requests here.
//...
//ENTER HERE THE SECOND TIME BUT WIFI IS FALSE BECAUSE WIFI STILL NO STARTS..
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
// Location settings are not satisfied. But could be fixed by showing the user
Toast.makeText(MainActivity.this, "Show dialog", Toast.LENGTH_SHORT).show();
try {
// Show the dialog by calling startResolutionForResult(),
// and check the result in onActivityResult().
status.startResolutionForResult(
MainActivity.this,
REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException e) {
// Ignore the error.
}
// }
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
// Location settings are not satisfied. However, we have no way to fix the
// settings so we won't show the dialog.
//...
break;
}
}
});
}