Send SMS from android application example


                Program to send SMS in Android is very simple to develop, its hardly two lines. Before explaining the code, left me give some basics about the class used in this example.


                Class that manages Android SMS operations such as sending data, text. We need to create object by calling the static method SmsManager.getDefault()

SmsManager.getDefault() - will get default instance of SmsManager 

Using this instance we need to call sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
For now, lets concentrate on two parameters in this method.

scAddress - This is used to specify the SMS service center to use. If you enter null, the default service center for the device carrier will be used.
destinationAddress - is the target phone number you wish to text
text - message to be send

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, sms, null, null);

That's it, simple it is..

                  Another critical part is to update Androidmanifest.xml, by adding this code to it

 <uses-permission android:name="android.permission.SEND_SMS" />

This grants permission for Android application to send sms.

Possible Exception: 

                 If you miss to add permission to SEND_SMS in Androidmanifest.xml, then you will receive error while sending message
"Sending sms message: Neither user nor current process has android.permission.SEND_SMS"

Output Screen
SMS Application

Code - Download complete project here

protected void onCreate(Bundle savedInstanceState) {
  btnSend = (Button) findViewById(;
  etPhoneNo = (EditText) findViewById(;
  etMsg = (EditText) findViewById(;
  btnSend.setOnClickListener(new OnClickListener() {    
   public void onClick(View v) { 
     String phoneNo = etPhoneNo.getText().toString();
     String msg = etMsg.getText().toString(); 
     try {      
    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(phoneNo, null, msg, null, null);    
    Toast.makeText(getApplicationContext(), "Message Sent",
     } catch (Exception ex) {

Thats it, its very simple enough to send sms in android application programmatically.

To confirm SMS/Message sent action and delivery in android, have a look at this example


Write comments
  1. excuse me...
    please help me...
    Do you have recommendations about MMS on Android reference?


  2. Can please help me with recieve SMS too..<3..thnks:)

  3. need to send sms and save them as a sent items for conversations any help?

  4. How to send sms by choosing contact from contact list..


Popular Posts

Find us on Facebook