Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query the MMS Log in Android

In my app I need to query both the SMS and the MMS log to get the history of all incoming and outgoing messages. This code has worked wonderfully for SMS:

Cursor c = cr.query(Uri.parse("content://sms"), null, null, null, null);

But when I try the following I get completely different results:

Cursor c = cr.query(Uri.parse("content://mms"), null, null, null, null);

The SMS query returns data that includes the message address (phone number), contact name, message subject, message body, etc... The same query for MMS returns a bunch of nulls or numeric value fields that I can't make any sense of. I really need a list of all MMS messages currently on the phone with the phone number or contact ID associated with it, and if the message was an incoming or outgoing message. In the SMS query results I can get the phone number from the address field, and the incoming/outgoing type from the type field but neither of these exist when I query for MMS.

Is there a different content Uri that I need to query for this sort of MMS data? Any help would be greatly appreciated.

Edit: Just to clarify, I'm completely aware that this is an unsupported content provider. However since there is no supported way of doing this I'm fully willing to test and support this on a per phone/per OS version basis. Just to keep the discussion on track lets say this question is specific to Android 1.6 on an HTC Dream (G1) or HTC Magic (MyTouch). How would you accomplish this task on that specific phone and OS version? Or if it's not possible on those, but it is possible on Android 2.0 on a Motorola Droid, then I would find that information very helpful as well. But regardless, lets stick to the discussion of how to accomplish this task in a supported or unsupported manner and not let it devolve into a discussion of how we should all stay away from things that aren't supported by the API, which is something I find the Android discussion groups to be riddled with and which I feel provides little to no help whatsoever. If I'm using an unsupported method, that's fine, show me the supported method of accomplishing that task. If there is no supported method, then why does the API support allowing me to request permission to read SMS via android.permission.READ_SMS?

like image 985
Mark B Avatar asked Jan 01 '10 01:01

Mark B


People also ask

How do I know if MMS is working?

Check the Android phone's network connection if you can't send or receiving MMS messages. An active cellular data connection is required to use the MMS function. Open the phone's Settings and tap “Wireless and Network Settings.” Tap “Mobile Networks” to confirm it is enabled.

How do I open a MMS?

Turn on your phone. Go to you message list. Click the preview of the MMS message to open it.


1 Answers

These are the content uris I've used in the past. You'll have to fiddle with the values you get back, and it's a long way from getting the parts of an MMS, but hopefully it'll help.

// root URI for MMS messages
static final String MMS_CONTENT_URI = "content://mms";

// root URI for MMS and SMS threads
public static final String MMS_SMS_CONTENT_URI = "content://mms-sms";

// URI of MMS inbox
public static final String RECEIVED_MMS_CONTENT_URI = MMS_CONTENT_URI + "/inbox";

// URI where sent MMSes are stored
public static final String SENT_MMS_CONTENT_URI = MMS_CONTENT_URI + "/sent";

// URI where sent MMSes are stored
public static final String MMS_PART_URI = MMS_CONTENT_URI + "/part";

// URI for incoming SMSes (also triggers on MMSes)
public static final String SMS_INBOX_URI = "content://sms/inbox";
like image 68
Ginger McMurray Avatar answered Sep 20 '22 14:09

Ginger McMurray