explaingit

tbruyelle/rxpermissions

10,426JavaAudience · developerComplexity · 2/5LicenseSetup · moderate

TLDR

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.

Mindmap

mindmap
  root((rxpermissions))
    What it does
      Wrap permission requests
      RxJava observable flow
      Handle grant or deny
    Supports
      Single permission
      Multiple permissions
      Permanent denial check
    Android versions
      Android 6 and above
      Android 5 always granted
    License
      Apache 2.0
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add runtime permission requests to an Android app without messy callback code.

USE CASE 2

Request multiple permissions at once and handle the result in a single RxJava stream.

USE CASE 3

Detect when a user has permanently blocked a permission dialog and show an explanation.

Tech stack

JavaRxJavaAndroid

Getting it running

Difficulty · moderate Time to first run · 30min

Requires an existing Android project with RxJava already configured.

Use freely for any purpose, including commercial use, as long as you keep the Apache 2.0 license notice.

In plain English

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.

Copy-paste prompts

Prompt 1
Using RxPermissions in my Android app, write code to request camera permission and show a rationale dialog if the user permanently denied it.
Prompt 2
Show me how to request both camera and storage permissions together with RxPermissions and handle each result separately.
Prompt 3
My app uses RxPermissions but I get a loop when the screen rotates, how do I set up the permission request in the right lifecycle method?
Prompt 4
Translate my existing ActivityCompat.requestPermissions code to use RxPermissions instead.
Open on GitHub → Explain another repo

← tbruyelle on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.