Showing a Dialog (Or Screen) From a Background Thread on BlackBerry

If you need to pop up a dialog or any screen actually from a process that runs in background on BlackBerry, it is fairly easy to do, unfortunately it is (as pretty much everything with BlackBerry development)  easy to figure out how to do.

The following piece of code should do the trick:


synchronized (Application.getEventLock())
{
	Ui.getUiEngine().pushGlobalScreen(new CLAScreen(), 1, UiEngine.GLOBAL_QUEUE);
}

There are also a few things you should be aware of when using this code:

  1. Your backgroud process should implement UiEngine. Easy way is to extend Application.
  2. If you change UiEngine.GLOBAL_QUEUE to UiEngine.GLOBAL_MODAL, the dialog will block your thread until it is closed