Android SDK MMS
Asked Answered
C

3

7

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.

Cimbri answered 16/12, 2009 at 12:45 Comment(2)
Seems to be an answer already posted: #2973345Stonyhearted
I am doing something similar HERE!!! #14453308Gear
G
3

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.

Glycoprotein answered 16/12, 2009 at 12:58 Comment(3)
Forgot to say, I don't want to fire up the messaging application. The MMS should be sent behind the scenes. Here is the full story: I have a desktop application that sends data over TCP sockets to the phone. The socket server on the phone receives the stream, parses the data, and determines what to do. In the case of SMS, it composes a new SMS and sends the message behind the scenes. I now need to know how to send a MMS behind the scenes. I already have the photo streaming from client / server(phone) working fine, just need to be able to send the MMS with out asking for user input.Cimbri
Unfortunately, there isn't an API provided for sending SMS; just the SmsManager class that you've already seen.Pages
is there any way to pass a phone number to it?Flame
N
3

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

Nucleolus answered 7/3, 2013 at 10:13 Comment(0)
S
0

I'd love to get an answer to this one myself. It seems like a gaping hole in the API right now, and it's ridiculous that SMS is supported but MMS is not.

You might be able to leverage the MMS application itself; there's code in there for sending the MMS. You can see the source at the Android source repository

Solder answered 24/2, 2010 at 10:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.