0

I know this is very basic, but I am not able to figure out why I am getting this.

I am running a splash screen, and in the splash screen I am running a background thread for performing my required operation to contact server.

After the background thread finishes its task, the listener in the splash screen creates an object for the next screen and sends it to the method below:

public void swapScreen(final TopNewsScreen _tn)
{
    UiApplication.getUiApplication().invokeLater(new Runnable(){
        public void run()
        {
            UiApplication.getUiApplication().popScreen();
            UiApplication.getUiApplication().pushScreen(_tn);
        }
    });

}

Help of any sort is welcome.

Joakim Johansson
  • 3,196
  • 1
  • 27
  • 43
varunrao321
  • 925
  • 2
  • 10
  • 18

3 Answers3

1

The code you posted looks fine. I've seen "push modalscreen called from noneventhread" happen when there is a Dialog.inform or Dialog.ask call somewhere on a background thread.

Double check your background thread, and make sure it doesn't try to throw up some UI.

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
0

popScreen() takes a screen as an argument, so there should be one there.

When the last (or only) screen your application has pushed to the display is removed, the application exits. I would suggest pushing _tn first, then poping the splash screen.

Richard
  • 8,920
  • 2
  • 18
  • 24
0

The better way to handle this situation is:

class SplashScreen extends FullScreen
{

protected void onObscured()
{
  close();
}
}

And simply push your screen (TopNewScreen) like you are doing. When the SplashScreen is not shown anymore, the screen closes by itself.

Kiran Kuppa
  • 1,457
  • 10
  • 18