blackberryjava-mesplash-screenblackberry-simulator

Splash screen image size


I am creating a splash screen for my BlackBerry app. Right now the image is not properly placed in all the simulators on which I am testing. What should be the size of my image for the splash screen, so that it fits in all the device sizes?


Solution

  • The main part is, creating Startup Class which extends UiApplication.

    This is the StartUp.java

    public class StartUp extends UiApplication
    {
    public static void main(String[]args)
    {
        StartUp start=new StartUp();
        start.enterEventDispatcher();
    }
    public StartUp() 
    {
        this.pushScreen(new SplashScreen());
        invokeLater(new Runnable() 
        {
            public void run() 
            {
                try 
                {
                    Thread.sleep(2000);// Sleeps it for few seconds
                    UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
                    pushScreen(new LoadingScreen());
                } 
                catch (Exception e) 
                {
                    exceptionHandling(e.getMessage());
                }
            }
        });
    
    }
    
    public static void exceptionHandling(final String exception)
    {
        UiApplication.getUiApplication().invokeLater(new Runnable() 
        {       
            public void run() 
            {
                Dialog.alert(exception);
            }
        });
    }
    }
    

    and the SplashScreen.java

    public class SplashScreen extends MainScreen
    {
    Bitmap bitmap=Bitmap.getBitmapResource("loading-screen.png");//This is my company logo;
    BitmapField loadingImage=new BitmapField(bitmap);
    public SplashScreen() 
    {
        createGUI();
    }
    
    private void createGUI() 
    {
        try 
        {
            VerticalFieldManager vertical=new VerticalFieldManager()
            {
                protected void paint(Graphics g) 
                {
                    g.drawBitmap(0, 0,Display.getWidth(),Display.getHeight(), bitmap, 0, 0);
                    super.paint(g);
                }
                protected void sublayout(int maxWidth, int maxHeight) 
                {
                    super.sublayout(Display.getWidth(),Display.getHeight());
                    setExtent(Display.getWidth(),Display.getHeight());
                }
            };
    
       //           Nothing to write;
    
            add(vertical);
        }
        catch (Exception e) 
        {
            StartUp.exceptionHandling(e.getMessage());
        }
    }
    }
    

    and your FirstScreen.java

    public class FirstScreen extends MainScreen
    {
    VerticalFieldManager vertical;  
    
    public FirstScreen()
    {               
        createGUI();
    }
    
    private void createGUI() 
    {
        setTitle("Loading Screen");
        vertical=new VerticalFieldManager()
        {
            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.sublayout(Display.getWidth(),Display.getHeight());
                setExtent(Display.getWidth(),Display.getHeight());
            }
        };
        add(vertical);
    }
    
    public boolean onMenu(int instance) 
    {
        return true;
    }
    }
    

    Try this you can get.