Showing a dialog (or screen) from a background thread on BlackBerry

Jun 9, 2009 by

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

Related posts:

  1. What makes blackberry app a super app – summary of webcast
  2. Android development vs. Blackberry Development
  3. BlackBerry Eclipse plugin 1.1 will fix some of the annoying problems
  4. New England BlackBerry Developer Meetup group – first meetup notes
  5. Load cod file to BlackBerry using JavaLoader