-2

I need to use the camera on one of my pages, but it won't work (NotAllowedError: Permission denied), and I tried to authorise the camera on my app via my device but it's still not wot working

I also added the authorisations on my Manifest:

<uses-permission android:name="android.permission.CAMERA" />

<uses-feature android:name="android.hardware.camera.any" android:required="false" /> But I think it's because I use jasonnette that the app use the authorisation of the navigator I display rather than the authorisations of the app itself

Maxim
  • 39
  • 3
  • 11
  • Did you add runtime permissions? Camera needs to be checked at runtime as well as in the manifest. – Gabe Sechan May 21 '19 at 15:04
  • Possible duplicate of [Android permission doesn't work even if I have declared it](https://stackoverflow.com/questions/32635704/android-permission-doesnt-work-even-if-i-have-declared-it) – Zoe May 21 '19 at 15:07

1 Answers1

0

You have to ask for the runtime permissions I did it this way in a project some time ago: First:

 ActivityCompat.requestPermissions(activity!!,
     arrayOf(android.Manifest.permission.CAMERA),
     PERMISSIONS_REQUEST_CAMERA)

Then:

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
    when (requestCode) {
        PERMISSIONS_REQUEST_CAMERA -> {
            if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                //do your stuff
            } 
            return
        }
    }
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
}

I hope this helps!

Samuel Luís
  • 171
  • 1
  • 7