To send a text message, use sendTextMessage from the SMS Manager, passing in the address (phone number) of your recipient and the text message you want to send, as shown in Listing 12-15.
LISTING 12-15: Sending an SMS message Available for String sendTo = "5551234";
Wrox°comn String myMessage = "Android supports programmatic SMS messaging!";
smsManager.sendTextMessage(sendTo, null, myMessage, null, null);
The second parameter can be used to specify the SMS service center to use; if you enter null as shown in Listing 12-15 the default service center will be used for your carrier.
The final two parameters let you specify Intents to track the transmission and successful delivery of your messages.
To react to these Intents, create and register Broadcast Receivers as shown in the next section.
The Android debugging bridge supports sending SMS messages among multiple emulator instances. To send an SMS from one emulator to another, specify the port number of the target emulator as the "to" address when sending a new message.
Android will automatically route your message to the target emulator instance, where it'll be handled as a normal SMS.
Was this article helpful?
Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.