RxPermissions 权限管理框架

网址链接:
RxPermissions GitHub 地址

依赖包版本 :

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

private void requestPermissions() {

        RxPermissions rxPermissions = new RxPermissions(this);
        rxPermissions.requestEach(Manifest.permission.READ_EXTERNAL_STORAGE,
                Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.READ_CALENDAR,
                Manifest.permission.READ_CALL_LOG,
                Manifest.permission.READ_CONTACTS,
                Manifest.permission.READ_PHONE_STATE,
                Manifest.permission.READ_SMS,
                Manifest.permission.RECORD_AUDIO,
                Manifest.permission.CAMERA,
                Manifest.permission.CALL_PHONE)
                .subscribe(new Consumer() {
                    @Override
                    public void accept(Permission permission) throws Exception {
                        if (permission.granted) {
                            // 用户已经同意该权限
                            Log.d("lrcoder", permission.name + " is granted.");
                        } else if (permission.shouldShowRequestPermissionRationale) {
                            // 用户拒绝了该权限,没有选中"不再询问", 那么下次再次启动时, 还会提示请求权限的对话框
                            Log.d("lrcoder", permission.name + " is denied. More info should be provided.");
                        } else {
                            // 用户拒绝了该权限,而且选中"不再询问"
                            Log.d("lrcoder", permission.name + " is denied.");
                        }
                    }
                });
    }

你可能感兴趣的:(RxPermissions 权限管理框架)