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:
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);
}
For future references, if someone encounters the problem in flutter related android projects:
https://github.com/apptreesoftware/flutter_barcode_reader/issues/32#issuecomment-420516729
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 :)
in your androidManifest, you have to add :
<uses-feature android:name="android.hardware.camera" />
here is an full Manifest example of android camera project