Open a MainScreen from another MainScreen

1.2k views Asked by At

In my app, I want to open a MainScreen from another MainScreen. How can I do this?

From UiApplication I can use pushScreen(Screen) to go to a MainScreen. But when I try the same from a MainScreen I get a JVM error 104.

2

There are 2 answers

4
Marc Paradise On BEST ANSWER

So let's say you have Screen2 extends MainScreen.


Screen2 s2 = new Screen2(); 
UiApplication.getUIApplication.pushScreen(s2); 

Note that the code above must be executed from within the main Ui event thread. If you're displaying the screen in response to an UI event, this is the default. However, if you're pushing the screen from a background thread, you'll need to marshall the call onto the event thread as follows:

UiApplication.getUiApplication().invokeLater( new Runnable() { 
    public void run() { 
     Screen2 s2 = new Screen2(); 
     UiApplication.getUIApplication.pushScreen(s2); 
    }
});
1
Mugur On
Ui.getUiEngine().pushScreen(Screen);