框架整理系列十五(Android M 权限)

2017-04-20  本文已影响0人  I_Gisvity

引用

   //rxAndroid
   compile 'io.reactivex.rxjava2:rxjava:2.0.8'
   compile 'io.reactivex.rxjava2:rxandroid:2.0.1'

   compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'

使用

RxPermissions rxPermissions = new RxPermissions(this); // where this is an Activity instance

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

猜你喜欢

热点阅读