0

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

AdamPI
  • 53
  • 6
  • "in other case it throws an exception" -- use Logcat to examine the stack trace associated with your exception. If you do not understand the stack trace or exception, edit your question with the entire stack trace, plus the code that generates that exception. – CommonsWare Jul 16 '23 at 12:53
  • If you could share the exception log it would be better to understand the problem. – Ahmad Reza Enshaee Jul 16 '23 at 14:31

0 Answers0