I am loading images into my app using startActivityForResult()
by doing something like this:
val intentForLoadingImage = Intent(Intent.ACTION_GET_CONTENT)
intentForLoadingImage.type = "image/*"
if (intentForLoadingImage.resolveActivity(packageManager) != null) {
startActivityForResult(intentForLoadingImage, IMAGE_REQUEST_CODE)
}
I have overridden onActivityResult()
with my logic for loading the image into an ImageView. It works on all android versions (my app's minSdkVersion is 21) but it does absolutely nothing on Android 11. Because intentForLoadingImage.resolveActivity(packageManager)
returns null and the activity for loading images doesn't start.
I learned about package visibility privacy updates on Android 11. Which says,
So, I added the following tags in my manifest file:
And that's it!