Send MMS using vCard on Android devices

I am trying to find a way to send an MMS message containing a vCard attachment. I thought it would be a fairly simple task, but I still could not come up with something that just works on a wide variety of Android phones.

The first thing I tried was:

Define an intent showing a list of apps that can send vCard

Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/x-vcard"); i.putExtra(Intent.EXTRA_TEXT,"MMS with vCard"); i.putExtra(Intent.EXTRA_STREAM, Uri.parse (someFilereference); startActivity(Intent.createChooser(i, "Select MMS application.")); 

When using this, I noticed the following:

  • In the Samsung Galaxy S , the selector allowed me to choose Bluetooth, Gmail, and the messaging app . When using the Messages application, the attachment and text were present, and I could send MMS. I processed MMS on an old Sony Ericson (pre-android) phone, and vCard was processed perfectly.
  • In Google Nexus S and Motorola DroidX , the selector allowed me to choose Bluetooth and Gmail. ( Messaging was not selected ).

(My conclusion): It seems that Android does not come with a stock application that can satisfy the task specified here. (no application allows the use of the text / x -vcard mimeType). Galaxy S comes with its own messaging app that is capable of handling mimetype vcard.

This is all very good, but how do we solve it and solve it?

I tried the following approach:

Run the messaging intent directly by specifying a class

 Intent intent = new Intent(Intent.ACTION_SEND); i.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity"); i.setType("text/x-vcard"); i.putExtra("sms_body", "SomeText"); i.putExtra(Intent.EXTRA_STREAM, Uri.parse (someFileRef); startActivity(i); 

Using this code, the messaging application runs directly. This approach was chosen because it at least allows us to add a messaging application on the Nexus S (previously, by choice, there was no messaging application).

In Samsung Galaxy S, the attachment is added to the MMS layout screen and sent correctly. There is no attachment on Google Nexcus S.

When uninstalling mimeType from Intent, the Messaging application adds the error message Unsupported media type .

So, the questions: is there a simple and uniform code that allows you to send MMS with vCard attachment?

+4
source share

Source: https://habr.com/ru/post/1345349/


All Articles