I'm using android 13 and I'm trying to obtain uri from PhotoPicker. Unfortunately the uri returned has a problem to be transfered to ImageView. Here is how I do it:
private val takeImageWithPhotoPicker = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
result.data?.data?.let { uri ->
binding.artwork.setImageURI(Uri.parse("content://media/picker/0/com.android.providers.media.photopicker/media/1000000125"))
}
}
I've put "content://media/picker/0/com.android.providers.media.photopicker/media/1000000125" on purpose because here is the main problem. If I just write binding.artwork.setImageURI(uri) everything works but in my case after giving uri as string it works only when uri(returned) is equal to "content://media/picker/0/com.android.providers.media.photopicker/media/1000000125" in other case it throws an exception