Pages Navigation Menu

Coding is much easier than you think

how to send sms in android application

how to send sms in android application

The android.telephony package contains the SmsManager and SmsMessage classes. The SmsManager defines many important SMS-related constants, and also provides the sendDataMessage, sendMultipartTextMessage, and sendTextMessage methods. As long as your app is configured with proper permissions to send text messages (using the android.permission.SEND_SMS permission) you can send text messages to whoever you like SmsManager to send SMS messages
** UPDATE: Android Complete tutorial now available here.

sendTextMessage ( 
String phoneNumber,
String serviceCenterAddress,
String text,
PendingIntent sentIntent,
PendingIntent deliveryIntent

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("9884788301", null, "hi simplecodestuffs!", sentPI, deliveredPI);

Sent Intent is a pending intent which will be triggered when sms is sent from your phone and delivery Intent is a pending intent which will be triggered when sms is delivered to the target phone.


private SmsManager smsManager;
public void onCreate(Bundle icicle) {
// . . . other onCreate view item inflation omitted for brevity
smsSend = (Button) findViewById(;
smsManager = SmsManager.getDefault();
final PendingIntent sentIntent =
this, 0, new Intent(this,
SmsSendCheck.class), 0);
smsSend.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String dest = smsInputDest.getText().toString();
if (PhoneNumberUtils.
isWellFormedSmsAddress(dest)) {
smsInputDest.getText().toString, null,
sentIntent, null);
"SMS message sent",
} else {
"SMS destination invalid - try again",


Before doing anything with SMS messages, we must obtain an instance of the SmsManager with the static getDefault() method . The manager will also send the message later. Before we can send the message, we need to create a PendingIntent to provide to the send method. A PendingIntent can specify an Activity, a Broadcast, or a Service that it requires. In our case, we use the getActivity() method, which requests an Activity, and then we specify the context, a request code (not used for this case), the Intent to execute, and additional flags . The flags indicate whether the system should create a new instance of the referenced Activity (or Broadcast or Service), if one doesn’t already exist. Next, we check that the destination address is valid for SMS , and we send the message using the manager’€™s sendTextMessage() method.

About Gokul

I am very much interested in android and Wicket framework. A core android developer and working in android native app development and responsive web mobile design. I have also worked in wicket fame work and java web development. I will keep on updating you about android and wicket framework and answer your query.