Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android SDK MMS

Tags:

android

mms

Does anyone know how to programmatically send a MMS via the Android SDK? Any version of the SDK will do, just need to know where to get started. I know how to send / receive SMS, I now need to add a picture to the message before sending.

like image 770
user160231 Avatar asked Dec 16 '09 12:12

user160231


2 Answers

For Sending an MMS is Android is as simple just like we send an SMS.
Here is the Code Snippet.

Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra("address","7404357000");
i.putExtra("sms_body","hello..");
i.putExtra(Intent.EXTRA_STREAM,Uri);
i.setType("image/png");
startActivity(i);
Here Uri is:

Uri uri = Uri.parse("content://media/external/images/media/1");
or
Uri uri = Uri.parse("file://mnt/sdcard/test.jpg");
or
Uri uri = Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/test.jpg");

Make sure that "test.jpg" is present or available in the SD Card.
You also need to give the permission in the Manifest file.

<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />

Here is the final Output on Emulator.
This code also work fine on Device
enter image description here

Here is the link

like image 43
Sumit Sharma Avatar answered Oct 20 '22 04:10

Sumit Sharma


This worked for me.

Intent sendIntent = new Intent(Intent.ACTION_SEND); 
sendIntent.putExtra("sms_body", "some text"); 
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/png"); 

The url being passed to the Uri.parse method should be of the form used to access the media store such as content://media/external/images/media/23.

From the series at jtribe.

like image 149
Billy Bob Bain Avatar answered Oct 20 '22 04:10

Billy Bob Bain