Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 13
Registered: ‎01-01-2013
My Device: BlackBerry Torch 9810
My Carrier: simple mobile

HOW To write Code for SPLASH SCREEN before the APP Loads

Can someone help me develop a splash screen for my blackberry app? Will appreciate any useful links. Am new to the blackberry app development.

Developer
Posts: 77
Registered: ‎04-01-2011
My Device: Bold 9700
My Carrier: Rogers

Re: HOW To write Code for SPLASH SCREEN before the APP Loads

public class WaitScreen extends PopupScreen {
        private LabelField pwLabel;

        public WaitScreen(){        
            super(new VerticalFieldManager(), VerticalFieldManager.USE_ALL_WIDTH |
                    VerticalFieldManager.USE_ALL_HEIGHT);

             pwLabel = new LabelField("Please wait...", LabelField.FIELD_HCENTER);
            add(pwLabel);
        }    

            
        public static void showScreenAndWait(final Runnable runThis) {
            final WaitScreen thisScreen = new WaitScreen();
            Thread threadToRun = new Thread() {
                public void run() {
                    // First, display this screen
                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            UiApplication.getUiApplication().pushScreen(thisScreen);
                        }
                    });
                    // Now run the code that must be executed in the Background
                    try {
                        runThis.run();
                    } catch (Throwable t) {
                        t.printStackTrace();
                        throw new RuntimeException("Exception detected while waiting: " + t.toString());
                    }
                    // Now dismiss this screen
                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            UiApplication.getUiApplication().popScreen(thisScreen);
                        }
                    });
                }
            };
            threadToRun.start();
        }
}

 

I use this code (it was taken from an example on this site somewhere). It is invoked (see below) by passing in a class that implements Runnable. It shows the screen, waits until the Runnable completes and then exits.

 

WaitScreen.showScreenAndWait(someRunnable);

 

Alternatively, you could not use a Runnable, but instead perform a Sleep() inside the showScreenAndWait() method.

 

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: HOW To write Code for SPLASH SCREEN before the APP Loads

Here is a simpler variation of the above - I prefer the above but this might help with concepts.

 

http://supportforums.blackberry.com/t5/Java-Development/Create-a-splash-screen/ta-p/444959