Search code examples
androidfilesmsvcf-vcard

Android - How to attach file to SMS?


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


Solution

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