Send VCard file/string via Whatsapp or mail programmatically

巧了我就是萌 提交于 2019-12-06 10:09:54

Try using EXTRA_TEXT instead of EXTRA_STREAM, as EXTRA_STREAM is supposed to point to a file.

Also, please delete the setPackage() call. You are not more important than your user. Your user, therefore, gets to control what app they share their vCard with, not you.

Beyond that, please contact Whatsapp for assistance with their app. Particularly given your setPackage() call, it is entirely possible that Whatsapp simply does not support vCard via ACTION_SEND.

Rijul

Try this:

intentShareFile.setDataAndType(Uri.fromFile(vcfFile),"text/x-vcard");
intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+vcfFile));

instead of:

intent.setType("text/x-vcard");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!