Reputation: 21
I'm using these line of code..
val uri = getUriForFile(this, BuildConfig.APPLICATION_ID+ ".provider" , file!!)
val shareIntent = Intent(Intent.ACTION_SEND)
shareIntent.type = "application/octet-stream"
if(model!!.path.endsWith("opus")){
shareIntent.setDataAndType(uri,"audio/*")
Toast.makeText(this,"audio",Toast.LENGTH_SHORT).show()
}else{
shareIntent.setDataAndType(uri,"*/*")
}
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
shareIntent.putExtra(Intent.EXTRA_STREAM, uri)
shareIntent.setPackage(Constants.whatsapp_package)
startActivity(createChooser(shareIntent, "send"))
this code work fine for other media files but did not share voice notes as like whatsapp
Upvotes: 1
Views: 318
Reputation: 21
saved file with .m4a extension and then use the same code as i mentioned in my question it works like charm on Huawei 8.1,Samsung 9 and nokia 9
Upvotes: 1