RxPermissions
Android runtime permissions powered by RxJava2
An Android library that wraps runtime permission requests (camera, contacts, etc.) in RxJava observables, so you can handle the request and response in one place instead of scattered callbacks.
RxPermissions is an Android library that makes it easier to ask users for permissions inside apps. Starting with Android 6.0 (called Android M at the time), apps can no longer assume they have access to things like the camera or contacts at install time. Instead, they must ask the user at the moment the feature is needed, and the user can grant or deny each permission individually. Handling that request and getting the yes or no answer back involves jumping between different parts of an app's code in a way that can be messy to organize.
This library solves that problem by wrapping the permission request in an RxJava observable, which is a programming pattern for handling events and responses in a more linear, readable flow. Instead of making a request in one method and waiting for a callback in a different method, you write the request and the response handling in the same place. You can request a single permission or multiple permissions at once, and the library gives you either a simple granted or denied result, or a more detailed object that also tells you whether the user has permanently blocked the dialog from appearing again.
The library handles older Android versions automatically: on devices running Android 5 or lower, where runtime permissions do not exist, it always reports the permission as granted without showing any dialog.
The README notes a timing constraint: the permission request must be set up during the app's initialization phase, not in a method that runs repeatedly during the app's lifecycle, or you may end up in a loop. The library is licensed under the Apache 2.0 license.
Where it fits
- Add runtime permission requests to an Android app without messy callback code.
- Request multiple permissions at once and handle the result in a single RxJava stream.
- Detect when a user has permanently blocked a permission dialog and show an explanation.