Tuesday, June 17, 2014
How to Send SMS From a Web Server to an Android Phone Using Java
1. Open the Java Eclipse software development program on your desktop. Open the Android project in which you want to add an SMS module. Double-click the Java file you want to use to send the message.
2. Add the wireless messaging library to the top of the file. You need this library to call the necessary functions. Copy and paste the following import statement to the top of the file:import javax.wireless.messaging.*;
3. Create a connection to the wireless phone number. The following code sets up a variable with the target phone number:this.connection=(MessageConnection) Connector.open('sms://5555555555:2948');The '2948' is the port number used to run the SMS service. Replace the '5555555555' with the mobile phone number you want as your recipient.
4. Set up the message content. The following code sets up a string variable with the content 'Hello, Recipient' as the message:String message ='Hello, Recipient';
5. Send the message. The following code packages the SMS message and sends it to your recipient phone number:this.connection.send(message);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment