Detecting MMS messages on Android
-
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 detects incoming MMS messages, how ever it does not detect them. here is the application: package com.kolomiyets.MMStesting; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.database.ContentObserver; import android.net.Uri; import android.os.Bundle; import android.widget.TextView; public class MMStesting extends Activity { public static final String MMSMON_RECEIVED_MMS = "MMStesting.intent.action.MMSMON_RECEIVED_MMS"; Uri mmsInURI = Uri.parse("content://mms"); ContentObserver mmsObserver = new ContentObserver(null) { @Override public void onChange(boolean selfChange) { Thread mmsNotify = new Thread(){ @Override public void run() { Intent mIntent = new Intent(MMSMON_RECEIVED_SMS); sendBroadcast(mIntent); super.run(); } }; mmsNotify.start(); super.onChange(selfChange); } }; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); BroadcastReceiver mmsMonitorBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { TextView log = (TextView)findViewById(R.id.mms_log); log.append("\n MMS Received;"); } }; IntentFilter mIntentFilter = new IntentFilter(); mIntentFilter.addAction(MMSMON_RECEIVED_MMS); registerReceiver(mmsMonitorBroadcastReceiver, mIntentFilter); getApplicationContext().getContentResolver().registerContentObserver(mmsInURI, true, mmsObserver); getApplicationContext().getContentResolver().notifyChange(mmsInURI, mmsObserver); } @Override protected void onDestroy() { getApplicationContext().getContentResolver().unregisterContentObserver(mmsObserver); super.onDestroy(); } } and the manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.kolomiyets.MMStesting" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="4" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.CALL_PHONE"/> <uses-permission android:name="android.permission.READ_CONTACTS"/> <uses-permission android:name="android.permission.WRITE_CONTACTS"/> <uses-permission android:name="android.permission.RECEIVE_SMS"/> <uses-permission android:name="android.permission.RECEIVE_MMS"/> <uses-permission android:name="android.permission.SEND_SMS"/> <uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_SMS"/> <uses-permission android:name="android.permission.WRITE_SMS"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.INSTALL_DRM"/> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".MMStesting" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> 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"? If it does not work in this app, than I won't be able to use this content in my database requests? If I'll detect changes with "content://sms" how can I distinguish between SMS and MMS? (I'd like to get what is in MMS as well). Or may be the best idea is just taking all those classes from android sources and trying to modify them the way I want? ...But I would'n like to do it))) Here is a http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.6_r2/android/provider/Telephony.java?av=f (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//part" and "content://mms/part/"? 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: http://code.google.com/p/android-notifier/source/browse/trunk/AndroidNotifier/src/org/damazio/notifier/service/MmsReceiver.java?r=141 is supposed to detect MMS messages with help of WAP Push Massages. I really can't make sense out of it. How?
-
Answer:
Here are some helpful links that I've found: http://www.anddev.org/other-coding-problems-f5/where-can-i-find-information-about-sending-receiving-mms-t51284.html http://www.anddev.org/acces_to_the_mms_part_file_content-t10433.html
Dima Kolomiyets at Stack Overflow Visit the source
Other answers
Detecting an incomming MMS message is easy, just put in broadcast receiver monitoring WAP_PUSH_RECIEVED events, as in... <receiver android:name=".PushReceiver"> <intent-filter> <action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" /> <data android:mimeType="application/vnd.wap.mms-message" /> </intent-filter> </receiver> Making sense out of what you get is a lot harder. I managed to decode everything I wanted from the WAP_PUSH_RECEIVED intent by cloning the PDU parsing code from the Mms app. Retrieving the actual contents from the part files is what I am still working on, which is how I found this topic in the first place.
kencorbin
Related Q & A:
- How To Receive Mms?Best solution by Yahoo! Answers
- How To Send MMS?Best solution by Yahoo! Answers
- Why can't iPhone do MMS?Best solution by Yahoo! Answers
- What's bigger for MMS texts?Best solution by Yahoo! Answers
- How to open unread mms on smart mms?Best solution by androidqueries.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.