I am trying to take a photo in kotlin with the following function:
@JavascriptInterface
fun generate() {
val photoUri = Uri.fromFile(photo)
val imageCaptureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.putExtra(MediaStore.EXTRA_OUTPUT, photoUri)
startActivityForResult(imageCaptureIntent, GO_TO_CARD_REQUEST_CODE)
}
My manifest has following permissions and features granted:
<uses-feature android:name="android.hardware.camera.any" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
When starting the activity an exception is shown in Logcat:
"java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.android.camera/.Camera". The camera application does not even start. How to solve this error? Thanks for any help.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…