Comments (2)
What I did in my app in that case is showing a single rationale for all requested permissions. It's simple but the caveat is you don't have the detail of which permissions has been revoked. So you can only display a message like "some critical permissions have been revoked, please go to the settings and fix that".
Here is a sample code of the method which is passed to the subscribe of request
. I used a snackbar for the user feedback :
private void onPermissionResult(Boolean granted) {
if (granted) {
// OK
return;
}
// Test whether the user clicked on "never ask again",
// adapt the action according to that.
RxPermissions.getInstance(this)
.shouldShowRequestPermissionRationale(this, CRITICAL_PERMISSIONS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(should -> {
SnackBar.Builder snack = new SnackBar.Builder(this)
.withMessageId(R.string.permission_required)
.withDuration(SnackBar.PERMANENT_SNACK)
.withStyle(SnackBar.Style.ALERT);
if (should) {
// "never ask again" not clicked, ask the user to retry the permission request.
snack.withActionMessageId(R.string.reask)
.withOnClickListener(token -> {
// Ask again for permissions
}
);
} else {
// "never ask again" clicked, ask the user to fix that in the app settings.
snack
.withActionMessageId(R.string.settings)
.withOnClickListener(token -> {
// Open the app settings
AndroidUtils.startAppDetailsActivity(this);
}
);
}
snack.show();
});
}
from rxpermissions.
thanks for your help
from rxpermissions.
Related Issues (20)
- Move library to maven central HOT 2
- I want to know about it's licensing
- How does it work with Android 11? HOT 1
- bug: request permission twice, in one subscribe receive callback twice
- 点击dialog外侧,dialog也会取消,且shouldShowRequestPermissionRationale=flase HOT 3
- Migrate to Maven Central
- Typo is Readme File HOT 3
- Bug:Can not perform this action after onSaveInstanceState
- Gradle import failed HOT 8
- Need to Migrate JCenter to mavenCentral HOT 5
- Cannot access class 'io.reactivex.rxjava3.core.Observable'. Check your module classpath for missing or conflicting dependencies HOT 2
- Bug: requestEach callback do not contain each permission result HOT 3
- Memory Leak
- FragmentTransition Bug
- Crash with new navigation library HOT 3
- Removing Jetifier
- android 11 中 获取应用列表时一个神奇现象
- Bug can not import packagename library HOT 2
- compileSdk 33,pixel 手机android 13,请求权限失败 HOT 7
- 没有subscribe方法 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxpermissions.