0

Hi I wanna add a SplashScreen to my Blackberry Application, i modified the code from here and modified it to this :

package main;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

import java.util.*;

public class SplashScreen extends MainScreen {
    private UiApplication application;
    private Timer timer = new Timer();
    private static final Bitmap _bitmap = Bitmap.getBitmapResource("SPlachS.png");
    public SplashScreen(UiApplication ui) {
        super(Field.USE_ALL_HEIGHT | Field.FIELD_LEFT);
        this.application = ui;
        this.add(new BitmapField(_bitmap));
        SplashScreenListener listener = new SplashScreenListener(this);
        this.addKeyListener(listener);
        timer.schedule(new CountDown(), 5000);
        application.pushScreen(this);
    }
    public void dismiss() {
        timer.cancel();
        application.popScreen(this);
        application.pushScreen(new MyScreen());
    }
.....


I just modified the constructor and that's all (i also tried the code from here) but I'm always having an Uncaught Runtime Exception

jprofitt
  • 10,874
  • 4
  • 36
  • 46
Mehdi
  • 974
  • 1
  • 10
  • 24

1 Answers1

8

For splash screen simply use this in your constructor..

Thread th = new Thread() 
        {
            public void run() 
            {
                try 
                { 
                    Thread.sleep(2000); 
                } catch (Exception ex) 
                { 
                }
                UiApplication.getUiApplication().invokeLater ( new Runnable() 
                    { 
                        public void run () 
                        {
                            UiApplication.getUiApplication().pushScreen(newScreen);
                            close();
                        }
                    }
                );
            }
        };
        th.start();

add everything to the screen before this thread.. I tried thid. hope it will work for u..

Swati
  • 1,179
  • 9
  • 28