質問

I'm trying to develop J2ME SMS applications (on Symbian, but that's not important).
I tried with the simplest app that sends a SMS when it receives one.
It is completely based on the example provided by JSR-205:

The base class is made implementing MessageListener.
Then the following methods are implemented (I left out all try/catch for simplicity).

I have two problems:

  1. it doesn't work
  2. I don't know how to debug it in Netbeans7.1

In particular I'm interested in an answer to the second question: how can I emulate an SMS reception in Netbeans7.1 in order to set a breakpoint in notifyIncomingMessage method?

public class Example extends MIDlet implements MessageListener {

    public void startApp() {
        messconn = (MessageConnection)Connector.open("sms://:6222");
        messconn.setMessageListener(this);
        reader = new Reader();
        new Thread(reader).start();
    }

    public void notifyIncomingMessage(MessageConnection conn) {
        conn = (MessageConnection)Connector.open("sms://+39xxxyyyyyyyy");
        TextMessage msg = (TextMessage)conn.newMessage("Hello");
        conn.send(msg);
    }
}

class Reader implements Runnable {
      public void run() {
          wait();
      }
}
役に立ちましたか?

解決

The J2ME Wireless Toolkit 2.0 supports WMA 1.1, allowing application developers to easily emulate sending and receiving SMS and CBS messages between multiple device emulators based on MIDP 2.0.So you can use The J2ME Wireless Toolkit WMA Console.
The console emulates a simple wireless messaging device. Each console instance - you can run more than one console at a time - is identified in its title bar by a unique number, referred to as its phone number to reflect the way a real device works. The first console is assigned the number 5550000 by default. If you immediately open a second console, it is assigned the number 5550001, and so on.
To use the console, start the toolkit's Preferences application, choose the API Availability tab, and make sure that the Wireless Messaging API is checked. Now run the Utilities application and on the right side of the window press the Open Console button. (You can also get to the Preferences and Utilities applications from menu items in the KToolbar application.)
To send a message from a console, press either the Send SMS or Send CBS button. The resulting dialog has two pages, one for text messages and one for binary messages. The SMS dialog lists the numbers of all console and emulator instances (collectively referred to as clients) currently running. Select the desired clients, enter the port number to which the message is to be sent, and either type the text message or select the binary file you want to send, then press the Send button. The CBS dialog is a bit simpler since the message will be broadcast to all known clients - supply a message identifier (a number) and the text or file to send, and press the Send button.
The console's main window lists the messages it sends and receives. You can use two console instances to chat with yourself, but it's much more interesting to involve an application in the conversation, so that you can verify that the application is sending and receiving messages correctly.
enter image description here

EDIT1:
In netbeans you can start WMA console from Tools | Java Platform | | Tools & Extensions | Open Utilities. Note that not all SDKs support this.On the other hand Go to your J2ME platform installed directory and search for some files look like utils.exe then double click on it.
EDIT2:
If you have problem yet,you can try other platforms.I have sony ericsson sdk 2.5.0.6 and it is easily to find "utils.exe" in it's installed directory.
You can see good tutorials and notes in references.
References:
Mobile P2P messaging, Part 1
The Wireless Messaging API
The J2ME Wireless Toolkit WMA Console
tebyan.net

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top