I have an app that has worked perfectly fine across all android versions and devices. But we just got a new device and this device doesn't work with my camera intent.
I am trying to take a picture and save it to a file. This device always returns RESULT_CANCELED, but when I check the file system a can see the picture created properly. I can also open it with no problems, so why is onActivityResult() returning RESULT_CANCELED, on this device only?
Device:
Samsung Galaxy Tab A8
Android 11
(fun fact: Tab A7 with Android 11 works fine)
Code:
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
val photo = File(getDSProDataDir(), "$filename.jpg")
val imageUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", photo)
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri)
camImageUri = Uri.fromFile(photo)
startActivityForResult(intent, TAKE_PICTURE)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
Log.d(TAG, "onActivityResult: rc: $resultCode, request: $requestCode, data: ${if (data == null) "null" else "yes"}")
// prints onActivityResult: rc: 0, request: 0, data: null
...
}