Send short messages by using

Source: Internet
Author: User

Send short messages by using

For more articles visit: http://blog.csdn.net/mailbomb

 

In the program, there are generally three ways to send short messages:

1. Use a program to send short messages on the Internet, such as text message services of various websites. In this way, the program sends the information to the gateway server of the carrier, and then sends the information to the mobile phone through the network of the carrier.

2. Connect to the mobile phone through the data cable in the computer, and then send short messages through the mobile phone. This method is implemented by using the AT command. At command of Ericsson mobile phone you can find in the following address: http://mobilityworld.ericsson.com.cn/development/download_hit.asp

3. Send short messages through a program running on the mobile phone. This is exactly how this article is implemented.

 

To send short messages, you must use the WMA package, which is included in midp2.0 and midp1.0.

Can be implemented through the extension API provided by the vendor, which is basically the same as the WMA class library.

The following is a simple method to send short messages to a specified mobile phone number using WMA. Of course, WMA also provides other methods to send more content.

 

// Smsutil. Java

Package my. util;

 

Import javax. Wireless. messaging .*;

Import javax. microedition. Io .*;

 

/**

* Method for sending text messages

*/

 

Public class smsutil {

/**

* Send short messages to a specified number

* @ Param content Short Message Content

* @ Param phonenumber: mobile phone number

* @ Return returns true if the message is sent successfully. Otherwise, false is returned.

*/

Public static Boolean send (string content, string phonenumber ){

// Return Value

Boolean result = true;

Try {

// Address

String address = "SMS: //" + phonenumber;

// Establish a connection

Messageconnection conn = (messageconnection) connector. Open (Address );

// Set the Short Message Type to text. The Short Message type can be text or binary.

Textmessage MSG = (textmessage) Conn. newmessage (messageconnection. text_message );

// Set the Information Content

MSG. setpayloadtext (content );

// Send

Conn. Send (MSG );

} Catch (exception e ){

Result = false;

// Not processed

}

Return result;

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.