Thursday, February 05, 2009

 

Minimal code to send a SMS from Google Android

A minimal code for sending a SMS message from the Google Android OS.

This code assumes you're in an Activity, which is where it gets this:

PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(), 0)

SmsManager smsManager = SmsManager.getDefault();

String receiver = "5556"; // the phone number of the device to send the SMS message to.

String message = "This is the SMS message I want to sending";

smsManager.sendTextMessage(receiver, null, message, pendingIntent, null);


What it requires from this is actually just the interface to the Context.

The <uses-permission android:name="android.permission.SEND_SMS"></uses-permission> is also required your build's AndroidManifest.xml file

Labels:


Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]