user935375
user935375

Reputation:

J2ME app does not work in Nokia n81 and Samsung f330, etc. but in works in BB and Nokia n97, etc

I did a little app in J2ME, it just open the browser with a target link.

Nevertheless, it works in some models of phones and in others it does not.

It works in:

Id does not work in:

I don't know why it works in some phones and in others don't. In theory, it should work with every phone with support of J2ME (JavaME).

EDIT: Here is the relevant code.

protected void startApp() throws MIDletStateChangeException {
        // TODO Auto-generated method stub

    boolean mustExit = false;
    try {

        /**
         * mustExit - Boolean
         * 
         * Some MIDP platforms are more restricted than others.
         * For example, some don't support concurrent processing,
         * so the MIDlet must exit before the platform can honor
         * a service request.
         * 
         * If <true> destroy the app. So the browser
         * can start.
         */
        mustExit = platformRequest("http://www.stackoverflow.com");
    } catch (ConnectionNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if(mustExit){
        destroyApp(true);
        notifyDestroyed();
    }

    //Display.getDisplay(this).setCurrent(timeAlert);

}

Upvotes: 4

Views: 364

Answers (1)

funkybro
funkybro

Reputation: 8671

You shouldn't be doing stuff like platformRequest in a lifecycle method such as startApp(). It's an asynchronous operation, it needs to ask the user for permission etc. This should not be done on the system thread.

Methods called on the system thread should return as close to immediately as possible, because the thread will likely be in charge of doing other stuff like screen redrawing, or processing user input. platformRequest is a blocking operation and will cause your device to freeze.

Some devices can handle this better than others which is why you're seeing the discrepancy.

Kick off a new thread to do the platformRequest and all should be well; you can start your new thread pretty much anywhere.

Upvotes: 5

Related Questions