PermissionX - 一行代码解决权限申请

作者: Season_zlc | 来源:发表于2020-02-16 17:36 被阅读0次

    PermissionX

    申请权限也能使用协程?Why not?

    使用方法

    权限申请只需一行代码

    launch {
        try {
            val result = request(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)
            if (result.isGranted) {
                //Now we have storage permission.
            }else {
                if (result.shouldShowRational) {
                    //Show permission rational
                }
                if (result.alwaysDenied) {
                    //User always denied our permission
                }
            }
        } catch (t: Throwable) {
            Log.w("TAG", t)
        }
    }
    

    Github地址

    相关文章

      网友评论

        本文标题:PermissionX - 一行代码解决权限申请

        本文链接:https://www.haomeiwen.com/subject/ijkmfhtx.html