farhan butt
farhan butt

Reputation: 21

how could i share whats app voice notes (.opus) file form my android app?

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

Answers (1)

farhan butt
farhan butt

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

Related Questions