Closed john990 closed 8 years ago
I didn't understand
Close because no response
Same issue for that permission (defined in manifest also). Let's try to re-open issue. my test code inside of onCreate in activity:
new RxPermissions(this)
.requestEach(Manifest.permission.CHANGE_NETWORK_STATE, Manifest.permission.WRITE_SETTINGS, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
.subscribe(permission -> {
if (permission.granted) {
// granted
} else {
Toast.makeText(this, "You must allow required permission " + permission.name, Toast.LENGTH_LONG).show();
}
});
You will see not granted toast. tested on android emulators - api 23/24 and on asus zenfone max 3 api 24. Only location request dialog is visible to user.
I've the same issue on an LG5 (Android 7.0): WRITE_SETTINGS dialog never appears. It always ends up in the Permission denied (never asked again).
There are some SO entries on WRITE_SETTINGS with people having the same issue:
This is my minimalistic code (the manifest not listed):
build.gradle:
dependencies {
// ... left out some defaults:
compile 'io.reactivex.rxjava2:rxjava:2.1.7'
compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'
}
MainActivity.java:
import android.Manifest;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.jakewharton.rxbinding2.view.RxView;
import com.tbruyelle.rxpermissions2.RxPermissions;
public class MainActivity extends AppCompatActivity {
private final static String TAG = "MAINAPP";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RxPermissions rxPermissions = new RxPermissions(this);
rxPermissions.setLogging(true);
setContentView(R.layout.activity_main);
RxView.clicks(findViewById(R.id.button))
.compose(rxPermissions.ensureEach(
Manifest.permission.CAMERA,
Manifest.permission.ACCESS_WIFI_STATE,
Manifest.permission.CHANGE_WIFI_STATE,
Manifest.permission.WRITE_SETTINGS))
.subscribe(permission -> {
if (permission.granted) {
Log.d(TAG, "Permission granted for " + permission.name);
} else if (permission.shouldShowRequestPermissionRationale) {
Log.d(TAG, "Permission denied (can ask again) for " + permission.name);
} else {
Log.d(TAG, "Permission denied (never asked again) for " + permission.name);
}
});
}
}
should like this...