I am using the code to share in an Mp4 video in WhatsApp
private fun shareVideoToApp(context: Context, packageName: String) {
sharePath?.let { path ->
val file = File(path)
startActivity(Intent().apply {
action = Intent.ACTION_SEND
setPackage(packageName)
putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(context, context.packageName + ".provider", file))
type = "video/*"
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
})
} ?: run {
Log.e(TAG, "Path is null")
}
}
The share path variable has value
/storage/emulated/0/Android/data/com.sample.androidapp/files/Download/VideoSnippets/1632536010_0_9265.mp4