val share: Intent
try {
share = Intent(Intent.ACTION_SEND)
share.putExtra(Intent.EXTRA_TEXT, shareString)
if (media != null) {
share.putExtra(Intent.EXTRA_STREAM, media)
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
if (FileUtilities.isAnAudio(media.path)) {
share.type = "audio/*"
} else if (isVideo) {
share.type = "video/*"
} else {
share.type = "image/*"
}
} else {
share.type = "text/plain"
}`
}
// Here media is the media uri
// Sharing for the video working fine but when I try to share an image I am getting the error that file format not supported enter image description here