Android: Permission Denial: starting Intent with revoked permission android.permission.CAMERA

后端 未结 10 1313
一个人的身影
一个人的身影 2020-11-29 07:47

I\'m trying to start a ACTION_IMAGE_CAPTURE activity in order to take a picture in my app and I\'m getting the error in the subject.

Stacktrace:

相关标签:
10条回答
  • 2020-11-29 08:44
    private String [] permissions = {"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.READ_PHONE_STATE", "android.permission.SYSTEM_ALERT_WINDOW","android.permission.CAMERA"};
    

    on your OnCreate add this:

    int requestCode = 200;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        requestPermissions(permissions, requestCode);
    }
    
    0 讨论(0)
  • 2020-11-29 08:45

    For future references, if someone encounters the problem in flutter related android projects:

    https://github.com/apptreesoftware/flutter_barcode_reader/issues/32#issuecomment-420516729

    0 讨论(0)
  • 2020-11-29 08:47

    In my case the problem was related to my emulator permissions ,

    To fix the issue :

    1- Go to Settings of your emulator.

    2- Look for Apps and Notifications.

    3- Click on Add Permission.

    see the pic : https://i.stack.imgur.com/z4GfK.png

    4- Select Camera of the list.

    5- Look for your Application in the provided list.

    6- Enable Camera.

    see the pic : https://i.stack.imgur.com/dJ8wG.pngEnjoy

    Now you can use your camera on your emulator :)

    0 讨论(0)
  • 2020-11-29 08:50

    in your androidManifest, you have to add :

     <uses-feature android:name="android.hardware.camera" />
    

    here is an full Manifest example of android camera project

    0 讨论(0)
提交回复
热议问题