How to send SMS using WMA JSR-120 in JavaME J2ME
August 23rd, 2007 Posted in J2ME / JavaME, newbie
Here a basic way on how to send SMS programatically from within JavaME / J2ME application using Wireless Messaging API (JSR-120).
WMA JSR-20 Code Snippets
JAVA:
-
import javax.wireless.messaging.*;
-
import javax.microedition.io.*;
-
-
...
-
try {
-
MessageConnection conn = (MessageConnection) Connector.open(addr);
-
TextMessage msg =
-
(TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE);
-
msg.setPayloadText("SMS Demo to " + text );
-
-
conn.send(msg);
-
//do something
-
-
//do something
-
}
As with other networking code, you need to execute this in a separate thread from the main MIDlet application (i.e commandAction), to avoid potential deadlocks.
Download complete working MIDlet application that demonstrates Wireless Messaging API code : SMSDemo.zip
[tags]java,j2me,javame,midlet,mobile,application,jsr-120,nokia[/tags]
October 9th, 2008 at 7:26 am
This is very good example for the newbies like myself.
The only problem I had with it, I tried to run it from the NetBeans 6.1 IDE and it didn’t work :( (?)
I mean, message was not received.
But then I loaded built jar/jad files on my Nokia 6265i and run it.
And it worked!
So, what could be wrong with the NetBeans IDE?
January 3rd, 2010 at 8:06 pm
Hi I am getting the following error
Exception in thread “main” java.lang.UnsatisfiedLinkError: getProperty0
at com.sun.midp.Configuration.getProperty0(Native Method)
at com.sun.midp.Configuration.getProperty(Unknown Source)
Can anybody help me