How to ask runtime permissions for Camera in Android , Runtime storage permissions

后端 未结 6 1010
迷失自我
迷失自我 2020-12-01 16:47

I am doing an application to scan barcodes on a button click and it was working fine up to Lollipop versions. When I came to Marshmallow it stopped working. This is the erro

6条回答
  •  Happy的楠姐
    2020-12-01 17:06

    After having it defined in your manifest file, a friendlier alternative to the native solution would be using Aaper: https://github.com/LikeTheSalad/aaper like so:

    @EnsurePermissions(permissions = [Manifest.permission.CAMERA])
    private fun takePhoto() {
        // Your code that needs the camera permission granted.
    }
    

    Disclaimer, I'm the creator of Aaper.

提交回复
热议问题