I need to send the document created from my app to only gmail and whatsapp.
for whatsapp I got the working code,
val filelocation = GlobalVariables.getMyFilePath(this, "dummy_file.mem")
val uri = Uri.parse(filelocation.absolutePath)
val whatsappIntent = Intent(Intent.ACTION_SEND)
whatsappIntent.type = "text/plain"
whatsappIntent.setPackage("com.whatsapp")
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "members file list")
whatsappIntent.putExtra(Intent.EXTRA_STREAM, uri)
whatsappIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
this.startActivity(whatsappIntent)
based on this I just follwed the same for gmail. but the is not getting attached. it toast message file not attached
val email = Intent(Intent.ACTION_SEND)
email.setPackage("com.google.android.gm")
email.putExtra(Intent.EXTRA_EMAIL, arrayOf<String>("vikas16acharya@gmail.com"))
email.putExtra(Intent.EXTRA_SUBJECT, "members file list")
email.putExtra(Intent.EXTRA_TEXT, message)
email.putExtra(Intent.EXTRA_STREAM, uri)
email.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
email.type = "message/rfc822"
this.startActivity(email)
- how to send attachment to gmail
- how to show only
whatsapp
andgmail
in chooser intent action