I'm querying for activities using queryIntentActivities which worked fine in api level 29, but as soon as I upgraded to level 30 the result is always empty.
This is the intent:
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
intent.putExtra("android.intent.extras.CAMERA_FACING", typeCamera)
uri?.grantWriteForIntent(activity, intent)
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri)
if (intent.isIntentSafe(activity)) {
activity.__waitResult__ = true
activity.startActivityForResult(intent, requestCode)
}
Then the isIntentSafe
function:
fun Intent?.isIntentSafe(context: Context) =
if (this == null)
false
else
context.packageManager.queryIntentActivities(this, PackageManager.MATCH_DEFAULT_ONLY).size > 0
This is where queryIntentActivites
is empty in level 30 and has content in level 29. Does anyone know what changed between these level which could have this effect?
I should add that if I skip the isIntentSafe
check in both api levels the activity starts fine anyway. But I want to know why isIntentSafe stopped working in the newer api.
EDIT: I have tried changing the intent for the front facing camera like in this answer How to launch front camera with intent? which doesn't make a difference.