如何使用 Jetpack Compose 请求权限? [英] How request permissions with Jetpack Compose?

查看:156
本文介绍了如何使用 Jetpack Compose 请求权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应如何实现向 Jetpack Compose View 请求许可?我正在尝试使用 Jetpack Compose 实现访问相机的应用程序.我尝试了 How to get Current state or context inJetpack Compose 不幸的是示例不再适用于 dev06.

How should be implemented requesting permission from Jetpack Compose View? I'm trying implement application accessing Camera with Jetpack Compose. I tried example from How to get Current state or context in Jetpack Compose Unfortunately example is no longer working with dev06.

        fun hasPermissions(context: Context) = PERMISSIONS_REQUIRED.all {
            ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_GRANTED
        }
    }
}

推荐答案

查看 Google Accompanist 的 Jetpack Compose 权限.

Check out Google Accompanist's Jetpack Compose Permissions.

请记住,在撰写本文时,该 API 仍被认为是实验性的,并且在使用时需要 @ExperimentalPermissionsApi 注释.

Bear in mind that, at the time of writing, the API is still considered experimental and will require the @ExperimentalPermissionsApi annotation when used.

这篇关于如何使用 Jetpack Compose 请求权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆