Derek Smith

Greenhorn
+ Follow
since Jan 28, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Derek Smith

I am pretty consistently experiencing problems with the Palm Emulator used with J2ME code. I can run the same code on other emulators within Forte/J2ME Toolkit and have no problems, but then when I switch to the Palm_OS emulator, I'll get a failure every time.
Code is opening an HTTPConnection, sending POST data and then creating inputDataStream to receive results. I call the same routine for each HTTP request...first time is fine, second time is fine, third time fails with NullPointerException on in=conn.openDataInputStream() call.
I have tried to make sure to close connections and clean up variables (general J2ME good practice) but again, I only experience this on the Palm OS emulator.
Any insight is appreciated!
DMS
19 years ago
I had the same problem. Just putting the package into the same directory structure is not enough...you also have to reference it in the MIDlet Suite that is created.
I use Forte with the J2METK add-in. In there, right click on the MIDlet Suite, select open, and on the 'Content' tab, make sure the directory for kXML is added to the 'Chosen Content' list.
I know this worked for kXML, and I suspect it would be the same for other external libraries.
19 years ago
Absolutely! J2ME includes packages for handling network communications including HTTP. So, in the same way that you could build an n-tier application that accesses a DB via a browser, you can build one that uses the mobile device as the client. What's even better is that the client can be very rich since Java is a full blown language, not just scripting (as in HTML or WAP).
Check out MIDP package javax.microedition.io for usage.
19 years ago
I have done what you are asking by putting thread creation and starting in the commandAction() routine of the Midlet. This is a common way to handle background/multithreaded network connections, etc.

else if (c == cmdGo) {
//call login routine
frmProgress.setCommandListener(this);
disMain.setCurrent(frmProgress);

String strUID = txtUID.getString();
String strPIN = txtPIN.getString();

//create thread for login
INETThread login = new INETThread(INETThread.LOGIN, strUID, strPIN);
login.start();
The thread will run but any code that follows from the .start() will allow control of phone by user..so you can display a screen, etc.
Check out http://wireless.java.sun.com/midp/articles/threading/ for good example.
DMS
It has become quickly clear to me that the MIDP API has made a few changes to the java.util.Random class, particularly getting rid of the Random.nextDouble() method.
So, how would you create a pseudorandom number between x and y using only the nextInt() method? I have tried a number of varieties and none have yielded accurate results.
Thanks in advance...
DMS
19 years ago