Android - How to attach file to SMS?

纵然是瞬间 提交于 2019-12-30 07:09:06

问题


I need to send contact via SMS. So, I'm using .vcf file.

Still, I need to attach it to sms within android SDK. There IS such function within android. I've tried it on my smartphone;

I was searching for the way to do that for days and everything I've found so far was this nice library to construct vCard and this method of SMSManager class.

Does anyone know how to do that??? I suppose solution of this problem shall work not only for vcf, but for any file extension.

If you'll add some code as an example you will make me happy))


回答1:


Since you have a File object, you can send MMS with it, by using this code

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/x-vcard");
sendIntent.putExtra(Intent.EXTRA_STREAM,
    Uri.parse(outputFile.toURL().toString()));
startActivity(sendIntent);



回答2:


I think you need to use MMS intends of SMS AFAIK SMS is just text and in MMS you can add files.

see the following stackoverflow question and also this blog entry



来源:https://stackoverflow.com/questions/10420312/android-how-to-attach-file-to-sms

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