How to send short message by J2ME
This article mainly explains "J2ME how to send short messages." Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "J2ME how to send short messages"!
1. Create a connection
2. Set SMS type (text or binary).
3. Set information content
4, send specific
The code is as follows:
public class SendMessage { private String address = ""; //Send address public SendMessage(String messageContent, String phoneNumber) { address = "sms://" + phoneNumber; sendMeassage(messageContent, phoneNumber); } public boolean sendMeassage(String content, String phoneNumber) { try { //Make a connection MessageConnection conn = (MessageConnection) Connector.open (address); //Set the SMS type to TextMessage msg = (TextMessage) conn.newMessage(MessageConnection. TEXT_MESSAGE); //Set message content msg.setPayloadText(content); //Send conn.send(msg); } catch (Exception e) { return false; } return true; }}
At this point, I believe everyone has a deeper understanding of "how to send short messages in J2ME," so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!