I am making an Android app. I updated the target version from 28 to 33. I need to use the picture selector. I made it such that if the Build.VERSION.SDK_INT is higher than S_V2, then action MediaStore.ACTION_PICK_IMAGES is used. Otherwise Intent.ACTION_PICK used. I extracted it into a tool. However, when I use it elsewhere in the project, sometimes it works, but sometimes I get an exception. The exception that I get:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.provider.action.PICK_IMAGES cat=\[android.intent.category.DEFAULT\] dat=content://media/... typ=iamge/\* }
I don't understand why this exception is thrown. My code:
Intent intent = new Intent();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S_V2){
intent.setAction(MediaStore.ACTION_PICK_IMAGES);
} else {
intent.setAction(Intent.ACTION_PICK);
}
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
activity.startActivityForResult(intent, requestCode);
What should I do to solve the exception? Any help is appreciated.