2

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.

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
jfalexvijay
  • 3,681
  • 7
  • 42
  • 68
  • JVM error 104 is happening on a device, or a simulator? Also, you might want to explain what event causes the second screen to be pushed onto the UI stack. – Michael Donohue Feb 26 '11 at 17:20
  • From UiAppication I am showing one MainScreen (login screen). After validation, I have to go to another MainScreen. This app having more than one screen. How can I go from one screen to another ? – jfalexvijay Feb 26 '11 at 17:49
  • i have created the class like as follows; public class SecondScreen extends MainScreen{ . . . . . . } – jfalexvijay Feb 26 '11 at 17:51

2 Answers2

4
Ui.getUiEngine().pushScreen(Screen);
Mugur
  • 1,019
  • 9
  • 21
  • Hi I tried with Ui.getUiEngine().pushScreen(screen);. But I am getting following error. (JVM error 104). How to resolve it. – jfalexvijay Feb 26 '11 at 13:51
3

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); 
    }
});
Marc Paradise
  • 1,939
  • 17
  • 16
  • I have tested with your example code, but it is work with some issue. If I use "UiApplication.getUiApplication.pushScreen(Screen);", it is not showing first screen. It is showing last screen. Please help me to resolve this. – jfalexvijay Feb 28 '11 at 05:46
  • Sorry, I missed your reply until now. What I did above, would show the second screen (Screen2). If you have already displayed Screen2 and want to return to Screen1 (the first screen), you could use UiApplication.getUiApplication.popScreen(s1). Again, this must be done on the UI thread - so if the event triggering it is not a UI event, you'll need to wrap it in the same way as above. Does this help? – Marc Paradise Mar 10 '11 at 20:15
  • please check my first comment. I am getting some issue. Please help me to resolve it. – jfalexvijay Mar 11 '11 at 06:39
  • I need a bit more information - perhaps a brief example? If the above didn't help, I am not clear on what the problem is. – Marc Paradise Mar 11 '11 at 13:09