Detecting MMS messages.

Put your problem here if it does not fit any of the other categories.

Detecting MMS messages.

Postby kolomiyets.dima » Mon Mar 21, 2011 11:04 pm

Hi, I was searching through the internet for this topic and couldn't find any satisfying answer...
I'm trying to detect MMS messages (incoming at least for start). And I've decided to go through the way of detecting changes in the contents.

I've downloaded Android codes and made sure that I'm using correct content provider: "content://mms" (in android.provider.Telephony.Mms class) and I'm using all needed permissions (from Mms application).
I've come up with a sample application that should detect incoming MMS messages, how ever it does not detect them. here is the application:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.kolomiyets.MMStesting;
  3. import;
  4. import android.content.BroadcastReceiver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.IntentFilter;
  8. import android.database.ContentObserver;
  9. import;
  10. import android.os.Bundle;
  11. import android.widget.TextView;
  13. public class MMStesting extends Activity {
  15. public static final String MMSMON_RECEIVED_MMS = "MMStesting.intent.action.MMSMON_RECEIVED_MMS";
  17. Uri mmsInURI = Uri.parse("content://mms");
  19. ContentObserver mmsObserver = new ContentObserver(null) {
  20.     @Override
  21.     public void onChange(boolean selfChange) {
  23.         Thread mmsNotify = new Thread(){
  24.             @Override
  25.             public void run() {
  26.                 Intent mIntent = new Intent(MMSMON_RECEIVED_SMS);
  27.                 sendBroadcast(mIntent);
  28.       ;
  29.             }
  30.         };
  31.         mmsNotify.start();
  32.         super.onChange(selfChange);
  33.     }
  34. };
  36. /** Called when the activity is first created. */
  37. @Override
  38. public void onCreate(Bundle savedInstanceState) {
  39.     super.onCreate(savedInstanceState);
  40.     setContentView(R.layout.main);
  42.     BroadcastReceiver mmsMonitorBroadcastReceiver = new BroadcastReceiver() {
  43.         @Override
  44.         public void onReceive(Context context, Intent intent) {
  45.             TextView log = (TextView)findViewById(;
  46.             log.append("\n MMS Received;");
  47.         }
  48.     };
  50.     IntentFilter mIntentFilter = new IntentFilter();
  51.     mIntentFilter.addAction(MMSMON_RECEIVED_MMS);
  53.     registerReceiver(mmsMonitorBroadcastReceiver, mIntentFilter);
  55.     getApplicationContext().getContentResolver().registerContentObserver(mmsInURI, true, mmsObserver);
  56.     getApplicationContext().getContentResolver().notifyChange(mmsInURI, mmsObserver);
  59. }
  61. @Override
  62. protected void onDestroy() {
  63.     getApplicationContext().getContentResolver().unregisterContentObserver(mmsObserver);
  64.     super.onDestroy();
  65. }
  66. }
Parsed in 0.013 seconds, using GeSHi

and the manifest:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android=""
  3.  package="com.kolomiyets.MMStesting"
  4.  android:versionCode="1"
  5.  android:versionName="1.0">
  6. <uses-sdk android:minSdkVersion="4" />
  8. <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
  9. <uses-permission android:name="android.permission.CALL_PHONE"/>
  10. <uses-permission android:name="android.permission.READ_CONTACTS"/>
  11. <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
  12. <uses-permission android:name="android.permission.RECEIVE_SMS"/>
  13. <uses-permission android:name="android.permission.RECEIVE_MMS"/>
  14. <uses-permission android:name="android.permission.SEND_SMS"/>
  15. <uses-permission android:name="android.permission.VIBRATE"/>
  16. <uses-permission android:name="android.permission.INTERNET"/>
  17. <uses-permission android:name="android.permission.READ_SMS"/>
  18. <uses-permission android:name="android.permission.WRITE_SMS"/>
  19. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  20. <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
  21. <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  22. <uses-permission android:name="android.permission.WAKE_LOCK"/>
  23. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  24. <uses-permission android:name="android.permission.INSTALL_DRM"/>
  27. <application android:icon="@drawable/icon" android:label="@string/app_name">
  28.     <activity android:name=".MMStesting"
  29.              android:label="@string/app_name">
  30.         <intent-filter>
  31.             <action android:name="android.intent.action.MAIN" />
  32.             <category android:name="android.intent.category.LAUNCHER" />
  33.         </intent-filter>
  34.     </activity>
  36. </application>
Parsed in 0.003 seconds, using GeSHi

So far I tried "content://mms-sms" and application starts detecting something endlessly after device receives MMS message. There is no indication about new MMS in the status bar(as it should be), however the message appears in the incoming messages o_O...

Also I tried putting "content://sms" and everything works as it supposed to (detection of incomming and outgoing SMSs and even MMSs o_O)

Do I misunderstand something? Is there a way to correct my app so it would detect changes in "content://mms"?

Here are some helpful links that I've found: Where can I find information about sending/receiving MMS? Acces to the MMS part file content

And here is a Telephony class that contains MMS calass (also this site is convenient for browsing android source code)

This information somewhat describes, how to retrieve information from MMS messages that are in the database. However, I still can't figure out the way to detect ingoing and outgoing MMS messages.

It looks like to me that I have to to monitor "content://sms" in order to detect MMSs (since "content://sms" reacts on incoming MMSs and "content://mms" does not), and than work with "content://mms" over Cursor and ContentResolver.

But I'm not sure this is a right way... Also I don't understand what actually Part (or PduPart) represents... will i get a complete picture by retrieving Part from MMS or it will be a part of the picture? And is there any difference between "content://mms/<meaasage id>/part" and "content://mms/part/<message id>"?

Here is also an interesting moment with WAP Push Messages. As far as I've understood these represent some kind of some special SMS messages with hyper links, and they are also used to transfer configurations from mobile provider to client's phone. This class: is supposed to detect MMS messages with help of WAP Push Massages o_O... I really can't make sense out of it. How?

If someone has any ideas, please, share with me, I would be very glad, thanks.

PS: The parallel thread of my question is hanging on Detecting MMS messages on Android.
Posts: 2
Joined: Mon Mar 21, 2011 10:24 pm


Re: Detecting MMS messages.

Postby raj_J2ME » Tue Mar 22, 2011 11:50 am

I tried to search forum and found the link talking about the same issue,,

Check if this could help you.
Thanks with Regards,
Raj - The Kernel
Master Developer
Master Developer
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,

Re: Detecting MMS messages.

Postby kolomiyets.dima » Thu Mar 24, 2011 1:23 am

Hi, thank you for answering. As it is mentioned in my post, I've found these resources earlier, and I started making a mechanism of retrieving mms data. Still, there is no mention about how to detect changes in the mms content provider, so I could detect when a new mms was sent or received.
Posts: 2
Joined: Mon Mar 21, 2011 10:24 pm

Re: Detecting MMS messages.

Postby BmwFan » Tue Mar 29, 2011 11:49 pm

How are you doing with this?

This thread helped me a lot:

I only need incoming MMS, but it's coded to work with outgoing as well (I didn't test). Unfortunately it also only gives the recipient and not the sender, so I need to figure that out now. Let me know if you get any further, and I'll do the same.

Posts: 2
Joined: Mon Mar 28, 2011 2:35 am


Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests