[LIBRARY] Android SMS and MMS library

Search This thread


Senior Member
Feb 1, 2013


Senior Member
Jul 13, 2010


Inactive Recognized Developer
Dec 6, 2011
We're working on a security solution to temporarily disable receiving SMS, do you think your library could handle something like that?


New member
Sep 7, 2014
Is there a method for getting the APNs?

Is it possible to put out a small video that walks through the process of getting the library working.

I am so new and have a vision for a great sms app. But all I need is to understand how to actually use what you have made for us.

Sent from my SM-N900W8 using XDA Free mobile app


Senior Member
May 5, 2011
Austin, TX
I haven't been able to get sms or MMS sending to work.

I also tried the slideover-messaging app (compiled and installed apk) - and it doesn't seem to send the SMS either. It doesn't show any errors... just never goes out. This is on a GSM phone with a working SIM - and hangouts is the main SMS app.


Senior Member
Jul 31, 2011
Hey Klink, thanks a lot for this library. After going through your app and library, I see that the receiving mms part is missing. I am in need of some help with setting up a broadcast receiver that will handle incoming MMS messages. I would very much appreciate some help because I have been searching everywhere and I can not find a place where all the info I need is located.
Feel free to email me if you are willing to help me. [email protected] or just PM me on here.
Thanks a lot in advance.
Last edited:


New member
Dec 12, 2015
Permission and callbacks

Hi Klinker,
I have a few questions about your library:
- What is the limitation if application is not set as the default messaging application ?
- Is it possible to receive delivery and sent reports even if application is not defined as the default messaging app ?
- Is it possible to receive a report in case of MMS sending failure ? Is there any list of failure codes ?
- Does the library check the MMS part size against the maxMessageSize ?

Top Liked Posts

  • There are no posts matching your filters.
  • 8
    Hey guys, I put together a library to help anyone out there who is making an sms app after all my experience with Sliding Messaging and trying to get everything to work... I dug through way too much source code so hopefully this will save some others the trouble! Apologize if this isn't in the right spot mods!

    Android SMS/MMS/Google Voice Sending Library

    These are the APIs that Google has so far left out of the Android echosystem for easily sending any type of message without digging through source code and what not.

    This library is still in BETA and has a long way to go... APIs may not be final and things will most likely change.

    If you've got a better way to do things, send me a pull request! The library was created specifically for Sliding Messaging Pro and some things work the way they do specifically for that app.


    Library Overview

    Sending messages is very easy to do.

    First, create a settings object with all of your required information for what you want to do. If you don't set something, then it will just be set to a default and that feature may not work. For example, if you need MMS, set the MMSC, proxy, and port, or else you will get an error every time.

    Settings sendSettings = new Settings();
    sendSettings.setAccount("[email protected]");

    - MMSC - the URL of your mms provider, found on your phone's APN settings page
    - Proxy - more mms information that needs to be set for more providers to send
    - Port - again, more mms stuff
    - Group - whether you want to send message to multiple senders as an MMS group message or separate SMS/Voice messages
    - WiFi MMS Fix - will disable wifi to send the message, only way I've found to do it, so if you can find the problem, submit a pull request :)
    - Prefer Voice - send through Google Voice instead of SMS
    - Delivery Reports - request reports for when SMS has been delivered
    - Split - splits SMS messages when sent if they are longer than 160 characters
    - Split Counter - attaches a split counter to message, ex. (1/3) in front of each message
    - Strip Unicode - converts Unicode characters to GSM compatible characters
    - Signature - signature to attach at the end of messages
    - Send Long as MMS - when a message is a certain length, it is sent as MMS instead of SMS
    - Send Long as MMS After - length to convert the long SMS into an MMS
    - Account - this is the email address of the account that you want to send google voice messages from
    - RnrSe - this is a weird token that google requires to send the message, nullifying it will make the library find the token every time, I'll hit later how to save the token and save your users some data down below in the Google Voice section.

    Next, attach that settings object to the sender

    Transaction sendTransaction = new Transaction(mContext, sendSettings);

    Now, create the Message you want to send

    Message mMessage = new Message(textToSend, addressToSendTo);

    And then all you have to do is send the message

    sendTransaction.sendNewMessage(message, threadId)

    Note: threadId can be nullified, but this sometimes results in a new thread being created instead of the message being added to an existing thread

    That's it, you're done sending :)

    You'll also need to register a few receivers for when the messages have been sent and for delivery reports to mark them as read... In your manifest, add these lines:

    <receiver android:name="com.klinker.android.send_message.SentReceiver" >
            <action android:name="com.klinker.android.send_message.SMS_SENT" />
    <receiver android:name="com.klinker.android.send_message.DeliveredReceiver" >
                    <action android:name="com.klinker.android.send_message.SMS_DELIVERED" />

    Lastly, you'll need to include permissions in your manifest depending on what you want to do. Here are all of them:

    <uses-permission android:name="android.permission.SEND_SMS"/>
    <uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.WRITE_SMS"/>
    <uses-permission android:name="android.permission.RECEIVE_SMS"/>
    <uses-permission android:name="android.permission.RECEIVE_MMS"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.provider.Telephony.SMS_RECEIVED" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    Google Voice Overview

    To be able to send Google Voice messages, all you really need to do is add the final 3 permissions above and get the address of the Account that you want to send through.

    To get a list of accounts available on the device, you can use the following:

    ArrayList<Account> accounts = new ArrayList<Account>();
    for (Account account : AccountManager.get(context).getAccountsByType("com.google")) {

    Display those in a list and let the user choose which one they want to use and save that choice to your SharedPreferences.

    Next, when you are configuring your send settings, you should register a receiver that listens for the action "com.klinker.android.send_message.RNRSE" like so:

    if (sendSettings.getAccount() != null && sendSettings.getRnrSe() == null) {
        BroadcastReceiver receiver = new BroadcastReceiver() {
            public void onReceive(Context context, Intent intent) {
                sharedPrefs.edit().putString("voice_rnrse", intent.getStringExtra("_rnr_se")).commit();
        context.registerReceiver(receiver, new IntentFilter("com.klinker.android.send_message.RNRSE"));

    That code will then save the RnrSe value so that I don't have to fetch it every time and waste time and data. After it is saved, just insert that value into the send settings instead and you are good to go.


    And thats it, pretty simple to do, especially for MMS! There are some problems with the library at this point, so i'm really hoping someone out there who knows more about this stuff can help me out eventually and get everything cleaned up! I feel like this should be an important part of the Android APIs, yet it is all missing so this is my go at it! :)

    Have you got a link to your library?

    Great job. :good:

    Haha oops, that might be helpful ;) https://github.com/klinker41/android-smsmms
    Haha no, I built sliding from the ground up off of nothing, just referenced stock source when I needed to. Before I made this library, you had to download and import all kinds of internal classes not in the APIs, both from the stock app and just android source in general. This library brings all of those together so that you don't have to download hundreds of files to get the imports all sorted out (that took me days itself to do) and then it just allows you to use all those classes in a much easier way, really by only creating a message object and sending it through the transaction class.

    Basically, it does everything exactly the same as what you will see from the stock source, but it encapsulates all that so third party developers have much easier access to it and can worry about more important things in their app then sifting through source code to find out how to send a stupid MMS message ha. All of the MMS source can be sooooo confusing, especially if you're just starting out like I was. :p

    well I will def look at it when adding mms to SmartMessenger and let you know what I think :) We in the UK don't use MMS at all hardy, costs too much :)
    Say I have to send one simple SMS.
    How am I aware of either the success or the failure of the 'SEND' operation given that I do not ask for delivery report? Any sample code to do that like the sample you give in OP?
    Is it mandatory to specify MMSC URL/Proxy/Port in the sendSettings when just sending SMSes?

    Just register the sent broadcast receiver

    <receiver android:name="com.klinker.android.send_message.SentReceiver" >
            <action android:name="com.klinker.android.send_message.SMS_SENT" />

    If you are sending sms you don't have to set any of the settings if you don't want to, especially if you don't want delivery reports. It will fill everything in with default values when you create it and then you're good to send away
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone