I am sharing an audio file(opus file) from WhatsApp to my app. When I am trying to read the file using
val uri: Uri = intent.getParcelableExtra(Intent.EXTRA_STREAM)
val inputStream = contentResolver.openInputStream(uri)
val byteArray = IOUtils.toByteArray(inputStream)
I am getting an empty ByteArray
I've tried using BitmapFactory.decodeStream like this:
val uri: Uri = intent.getParcelableExtra(Intent.EXTRA_STREAM)
val inputStream = contentResolver.openInputStream(uri)
val bitmap = BitmapFactory.decodeStream(inputStream)
But BitmapFactory.decodeStream only returns null.
I also tried querying the content resolver for this uri, but all I get is the file name and the file size.
The uri value is "content://com.whatsapp.provider.media/item/133401"
However, when I am trying to share an image from WhatsApp to my App, and use the same code as above, everything works well and I get the desired byteArray.
I would love to have some help here
Thanks!