07-25-2009 11:36 AM
Hi,
We are trying to push the screen PopUpColeta (below) inside the TimeAuditor class which extends Thread (details below) but we get the following exception: "java.lang.IllegalStateException: UI engine accessed without holding the event lock"
public class PopUpColeta extends PopupScreen implements KeyListener
public class TimeAuditor extends Thread
UiApplication.getUiApplication().pushScreen(popUpC
For some reason the pushScreen command above works fine when we place it inside the MainScreen.
We are using BlackBerry Component Pack 4.5.0
Thanks!
07-25-2009 11:45 AM - edited 07-25-2009 11:47 AM
Place the pushScreen or popScreen inside of a Runnable and pass this Runnable to UiApplication.invokeLater()
Something like this:
/** * Stop the status display */ private void stopStatusDisplay() { if (m_statusDisplay != null){ m_app.invokeLater(new Runnable() { public void run()
{ m_statusDisplay.close(); m_statusDisplay = null; } }); } }
Note that I'm storing an instance of my application (m_app), since you can't always rely on UiApplication.getApplication(), depending on the context of the thread that is calling the UI.
07-25-2009 12:31 PM
07-25-2009 12:33 PM
This static method will return the current UiApplication, which may not be your application in certain circumstances.
For example, your app is called form a Message listener or Phone listener. In this case, the application context belongs to the calling app, not yours.