I was wondering how the people who develop for here BlackBerry go about managing the screens in their app. The most common practice (and the one I’m using) seems to be just to instantiate and push the new screen from the current one. The other option I’ve seen is using actions in the Main Application class to do the transitions. How do you guys manage?
Share
We have a
ScreenManagerclass manages the display of screens. It contains a Hashmap which has Screen name -> MainScreen pairs,public methods for adding and showing a screen.When our application starts up all the screens required are created and added to the
ScreenManagerclass.In the
showScreen()method we get the reference to the appropriateMainScreenclass. Then we useUiApplication.getUiApplication().popScreen(screen)to hide the current screen. If the screen has already been shown we simply usepopScreen()to remove screens until we reach the screen we want. Otherwise we justpushScreen()to move the screen to the top of the pile.Calls to using the
UiApplicationare contained within asynchronized(UiApplication.getEventLock())blockThis approach does the job for us. We can create all the screens once at the application startup so it does not need to be done over and over again during the course of the application.