Home > Uncategorized > How to Send SMS in Android

How to Send SMS in Android

It would be safe to say that nearly every mobile phone sold in the past decade has SMS messaging capabilities. In fact, SMS messaging is one great killer application for the mobile phone and it has created a steady revenue stream for mobile operators. Understanding how to use SMS messaging in your application can provide you with many ideas to create the next killer application.

Many new application will use SMS as data delivery platform. Reality shows, on-demand movies etc request users to send predefined formatted SMS. Similarly some applications are coming up which sends data to user using SMS. Let’s see how such an application can be built using Android platform.

Android API support developing applications that can send and receive SMS messages. The android emulator does not support sending of the SMS currently. But the emulator can receive SMS. Lets explore the android SMS support and develop a small program that listens to the SMSes received on the device (on emulator) and will show that message as notification.

You’ve got an Android application and you want to send an email, sms and mms via your application. But you don’t want to have to write a whole mail/mms/sms client. Thankfully Android provides a flexible way to forward responsibilities onto other applications installed on the device.

public void sendTextMessage(String destinationAddress, String scAddress,
String text, PendingIntent sentIntent, PendingIntent deliveryIntent) {

}

Way1

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
// use to fill the sms body
sendIntent.putExtra(“sms_body”, “Hi this is test sms”);
sendIntent.setType(“vnd.android-dir/mms-sms”);
startActivity(sendIntent);

Way2

// —sends an SMS message to another device—
@SuppressWarnings(“deprecation”)
private void sendSMS(String phoneNumber, String message) {
Log.v(“phoneNumber”, phoneNumber);
Log.v(“MEssage”, message);
PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this,
TMobileHome.class), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, pi, null);
}

Way3
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(“sms:”
+ “9999999999”)));

Advertisements
Categories: Uncategorized
  1. http://andcarinsurancequotes.com
    March 20, 2012 at 1:16 am

    Some really interesting points you have written.Aided me a lot, just what I was searching for :D.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: