阅读 102

动态鉴权(简单好用,一行代码搞定)

1引入依赖

dependencies {
      compile 'com.github.dfqin:grantor:2.5'
}
复制代码

2比如动态获取访问摄像头的权限,当然清单文件中要事先声明\

private void requestCemera() {
        PermissionsUtil.requestPermission(getApplication(), new PermissionListener() {
            @Override
            public void permissionGranted(@NonNull String[] permissions) {
                Toast.makeText(MainActivity.this, "访问摄像头", Toast.LENGTH_LONG).show();
            }

            @Override
            public void permissionDenied(@NonNull String[] permissions) {
                Toast.makeText(MainActivity.this, "用户拒绝了访问摄像头", Toast.LENGTH_LONG).show();
            }
        }, Manifest.permission.CAMERA);
    }
复制代码

github.com/dfqin/Permi…

文章分类
Android
文章标签