简单明了的权限申请库,再结合rxjava的话,用起来,一个字:爽
简单明了的权限申请库,再结合rxjava的话,用起来,一个字:爽RxView.clicks(findViewById(R.id.enableCamera)) .compose(rxPermissions.ensure(Manifest.permission.CAMERA)) .subscribe(granted -> { // R.id.enableCamera has been clicked });
rxPermissions .request(Manifest.permission.CAMERA, Manifest.permission.READ_PHONE_STATE) .subscribe(granted -> { if (granted) { // All requested permissions are granted } else { // At least one permission is denied } });
rxPermissions .requestEach(Manifest.permission.CAMERA, Manifest.permission.READ_PHONE_STATE) .subscribe(permission -> { // will emit 2 Permission objects if (permission.granted) { // `permission.name` is granted ! } else if (permission.shouldShowRequestPermissionRationale) { // Denied permission without ask never again } else { // Denied permission with ask never again // Need to go to the settings } });
rxPermissions .requestEachCombined(Manifest.permission.CAMERA, Manifest.permission.READ_PHONE_STATE) .subscribe(permission -> { // will emit 1 Permission object if (permission.granted) { // All permissions are granted ! } else if (permission.shouldShowRequestPermissionRationale) // At least one denied permission without ask never again } else { // At least one denied permission with ask never again // Need to go to the settings } });
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦