rx-java Android with RxJava Rxpermissions


Example

This library allows the usage of RxJava with the new Android M permission model.

Add the library to the dependencies:

Rxjava

dependencies {
    compile 'com.tbruyelle.rxpermissions:rxpermissions:0.8.0@aar'
}

Rxjava2

dependencies {
    compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.8.1@aar'
}

Usage

Example (with Retrolambda for brevity, but not required):

// Must be done during an initialization phase like onCreate
RxPermissions.getInstance(this)
    .request(Manifest.permission.CAMERA)
    .subscribe(granted -> {
        if (granted) { // Always true pre-M
           // I can control the camera now
        } else {
           // Oups permission denied
        }
    });

Read more: https://github.com/tbruyelle/RxPermissions.