I have figured out how to send and receive SMS messages. To send SMS messages I had to call the
sendTextMessage() and sendMultipartTextMessage() methods of the SmsManager class. To receive SMS messages, I had to register a receiver in the AndroidMainfest.xml file. Then I had to override the onReceive() method of the BroadcastReceiver . I have included examples below.MainActivity.java
SMSReceiver.java
AndroidManifest.xml
However, I was wondering if you could send and receive MMS messages in a similar fashion. After doing some research, many examples provided on blogs simply pass an Intent to the native Messaging application. I am trying to send an MMS without leaving my application. There doesn't seem to be a standard way of sending and receiving MMS. Has anyone gotten this to work?Also, I am aware that the SMS/MMS ContentProvider is not a part of the official Android SDK , but I was thinking someone may have been able to implement this. Any help is greatly appreciated.UpdateI have added aBroadcastReceiver to the AndroidManifest.xml file to receive MMS messages
In the MMSReceiver class, the onReceive() method is only able to grab the phoneNumber that the message was sent from. How do you grab other important things from an MMS such as the file path to the media attachment (image/audio/video), or the text in the MMS?MMSReceiver.java
According to the Documentation of android.provider.Telephony:Broadcast Action: A new text based SMS message has been received by the device. The intent will have the following extra values: pdus - An Object[] od byte[]s containing the PDUs that make up the message. The extra values can be extracted using getMessagesFromIntent(android.content.Intent). If a BroadcastReceiver encounters an error while processing this intent it should set the result code appropriately.
Broadcast Action: A new data based SMS message has been received by the device. The intent will have the following extra values:pdus - An Object[] of byte[]s containing the PDUs that make up the message. The extra values can be extracted using getMessagesFromIntent(android.content.Intent). If a BroadcastReceiver encounters an error while processing this intent it should set the result code appropriately.
Broadcast Action: A new WAP PUSH message has been received by the device. The intent will have the following extra values:transactionId (Integer) - The WAP transaction ID pduType (Integer) - The WAP PDU type header (byte[]) - The header of the message data (byte[]) - The data payload of the message contentTypeParameters (HashMap<String,String>) - Any parameters associated with the content type (decoded from the WSP Content-Type header) If a BroadcastReceiver encounters an error while processing this intent it should set the result code appropriately. The contentTypeParameters extra value is map of content parameters keyed by their names. If any unassigned well-known parameters are encountered, the key of the map will be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If a parameter has No-Value the value in the map will be null.
Update #2I have figured out how to pass extras in aPendingIntent to be received by a BroadcastReceiver :Android PendingIntent extras, not received by BroadcastReceiverHowever, the extra gets passed to the SendBroadcastReceiver not the SMSReceiver. How can I pass an extra to the SMSReceiver? Update #3Receiving MMSSo after doing more research I saw some suggestions of registering a ContentObserver . That way you can detect when there are any changes to the content://mms-sms/conversations Content Provider, consequently allowing you to detect incoming MMS. Here is the closest example to get this to work that I have found: Receiving MMSHowever, there is a variable mainActivity of type ServiceController . Where is the ServiceController class implemented? Are there any other implementations of a registered ContentObserver ?Sending MMS As for sending MMS, I have come across this example: Send MMS The problem is that I tried running this code on my Nexus 4, which is on Android v4.2.2, and I am receiving this error:
The error gets thrown after querying the Carriers ContentProvider in the getMMSApns() method of the APNHelper class.
Apparently you can't Read APNs in Android 4.2What is the alternative for all those applications which use mobile data to perform operations (like sending MMS) and don't know the default APN setting present in the device? | |||||||||||||
|
When I have the exact same problem you describe above (Galaxy Nexus on t-mobile USA) it is because mobile data is turned off.
In Jelly Bean it is: Settings > Data Usage > mobile data Note that I have to have mobile data turned on PRIOR to sending an MMS OR receiving one. If I receive an MMS with mobile data turned off, I will get the notification of a new message and I will receive the message with a download button. But if I do not have mobile data on prior, the incoming MMS attachment will not be received. Even if I turn it on after the message was received. For some reason when your phone provider enables you with the ability to send and receive MMS you must have the Mobile Data enabled, even if you are using Wifi, if the Mobile Data is enabled you will be able to receive and send MMS, even if Wifi is showing as your internet on your device. It is a real pain, as if you do not have it on, the message can hang a lot, even when turning on Mobile Data, and might require a reboot of the device. And GO Through this code : http://downloads.ziddu.com/downloadfiles/14286605/SendMMS3.zip Hope this helps. | |||||||
|
There is not official api support which means that it is not documented for the public and the libraries may change at any time. I realize you don't want to leave the application but here's how you do it with an intent for anyone else wondering.
I haven't completely figured out how to do things like track the delivery of the message but this should get it sent.You can be alerted to the receipt of mms the same way as sms. The intent filter on the receiver should look like this.
| |||||||||
|
I dont think there is any sdk support for sending mms in android. Look here Atleast I havent found yet. But a guy claimed to have it. Have a look at this post.
Send MMS from My application in android | |||||
|