Help With Opening New Form From Network Thread (Using postResponse())

41 views
Skip to first unread message

Keen Student

unread,
Oct 2, 2013, 11:43:34 AM10/2/13
to codenameone...@googlegroups.com
I need to open a new form based on a result obtained from a network request.

The issue is that the code works "ONLY" on the feature phone simulator, and not on the other

j2me devices (NOKIA simulators).

The code i am using is (..abridged version)
@Override
protected void postResponse()
{if (response.equalsIgnoreCase("string"))
{
 
Formname f=new Formname();
f
.show();

}
}

 The above code IS NOT OPENING a form on the NOKIA j2me simulators.

I had a similar issue when working  with RIM and i solved it by using a run thread to resolve the issue. I tried it on codename one using the 
Display.getInstance().invokeAndBlock(new  Runnable()
{public void run(){
Formname f=new Formname();
f
.show();
--------


Still does not open a new form. PLEASE HELP



 

Shai Almog

unread,
Oct 2, 2013, 4:15:22 PM10/2/13
to codenameone...@googlegroups.com
The latter solution you used is wrong since it violates the EDT.
I'm assuming you have a progress indicator dialog which you are disposing later on (or is disposed automatically). Dialogs always return to the parent form on dispose.
Just make sure to dispose the parent dialog before invoking show(), its OK to dispose the dialog twice.

Keen Student

unread,
Oct 3, 2013, 3:41:39 AM10/3/13
to codenameone...@googlegroups.com
Yes i have a progress dialog...this is the code:
             r.setUrl("url");
                r.setPost(true);
            r.addArgument("email",area.getText());
             r.addArgument("password",pass.getText());
             InfiniteProgress prog=new InfiniteProgress();
              d=prog.showInifiniteBlocking();
             r.setDisposeOnCompletion(d);
             NetworkManager.getInstance().addToQueue(r);

Following your answer regarding disposing the dialog, i  subsequently enlarged the scope of the dialog like this:
Login.addActionListener(new ActionListener() {
         Dialog d;
 I now disposed it(again) on the postReponse() method:
@Override
    protected void postResponse() {
        d.dispose();
...............

 NewForm f=new NewForm();
       f.show();

This code works for the "Lumia" and "Feature phone" skins...BUT still does NOT WORK in the "Asha" and
"Nokia E71" skins that are the MAJOR phones i am targeting. Anticipating your response. Thanks.

Shai Almog

unread,
Oct 3, 2013, 2:59:11 PM10/3/13
to codenameone...@googlegroups.com
This should work on all devices, what else are you doing? Can you narrow this down to a more barebone approach and see what fails?
Can you run the EDT violation detection (simulator menu) to see if you have race conditions/illegal access?
Did you run in the debugger? Where are you "stuck" which thread which methods/monitors?
Reply all
Reply to author
Forward
0 new messages