jfalexvijay
jfalexvijay

Reputation: 3711

Open a MainScreen from another MainScreen

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.

Upvotes: 2

Views: 1274

Answers (2)

Marc Paradise
Marc Paradise

Reputation: 1939

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); 
    }
});

Upvotes: 3

Mugur
Mugur

Reputation: 1029

Ui.getUiEngine().pushScreen(Screen);

Upvotes: 4

Related Questions