Get the App
SLTechnology News&Howtos  ›  Development  › 

How to send short message by J2ME

Shulou Source: shulou.com Published: 2022-06-02 13:39:33 10月01日 Update

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!

Tags: Information content text type learning practical deeper binary code interest address practicality practical easy to operate method more friends website channel query Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology Microsoft macOS NVidia