RxPermissions 权限请求框架使用

1.资源文件

implementation 'com.tbruyelle.rxpermissions:rxpermissions:0.9.4'
implementation 'io.reactivex.rxjava2:rxjava:2.2.19'

2.引用包

import com.tbruyelle.rxpermissions.RxPermissions;
import io.reactivex.functions.Consumer;
import rx.functions.Action1;

3.代码

            RxPermissions rxPermissions = new RxPermissions(this);


            rxPermissions.request(Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.CHANGE_WIFI_STATE, Manifest.permission.REQUEST_INSTALL_PACKAGES)
                    .subscribe((Action1) aBoolean -> {
                        if (aBoolean) {
                            Toast.makeText(W5FunctionalselectionActivity.this, "同意权限", Toast.LENGTH_SHORT).show();
                        } else {
                            Toast.makeText(W5FunctionalselectionActivity.this, "拒绝权限", Toast.LENGTH_SHORT).show();
                        }
                    });

 

你可能感兴趣的:(库的使用,android)