Android的 - 如何附加文件以短信?短信、文件、Android

2023-09-06 19:25:04 作者:冷眸ゞ

我需要通过短信发送名片。所以,我使用的.vcf文件。

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

不过,我需要重视它在Android SDK中的短信。有内部的Andr​​oid这样的功能。我已经试了一下我的智能手机;

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

我在寻找做到这一点的天,一切的办法,我发现到目前为止是的这个不错的库来构建电子名片和的SmsManager的类此方法。

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.

有谁知道如何做到这一点???我想,这个问题的解决方案,将努力不仅为VCF,但对于任何文件扩展名。

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

如果您将添加一些code,例如,你会让我快乐))

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

推荐答案

既然你有一个文件对象,你可以发送彩信,它可以用这个code

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);