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

New Contributor
Posts: 3
Registered: ‎08-01-2012
My Device: 9700
My Carrier: Glo Nig

Splash Screen code error

I tried creating a creating a splash screen, on MyApplication.java class i used to code

package myapplicationpackage;
Import net.rim.device.api.ui.UiApplication;
public class MyApplication extends UiApplication{

public static void main(strg [ ] args) {
//TODO Auto-generated method stub

MyApplication theApp = new MyApplication ( );

the App.enterEventDispatcher ();

private MyApplication ()

pushScreen (new MyappMainScreen ());

With the MyappMainScreen class i coded

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 MyappMainScreen extends MainScreen {
public class SplashScreen extends MainScreen {
   private MainScreen next;
   private UiApplication application;
   private Timer timer = new Timer();
   private static final Bitmap _bitmap = Bitmap.getBitmapResource("image.png");
   public SplashScreen(UiApplication ui, MainScreen next) {
      super(Field.USE_ALL_HEIGHT | Field.FIELD_LEFT);
      this.application = ui;
      this.next = next;
      this.add(new BitmapField(_bitmap));
      SplashScreenListener listener = new SplashScreenListener(this);
      timer.schedule(new CountDown(), 5000);
   public void dismiss() {
   private class CountDown extends TimerTask {
      public void run() {
         DismissThread dThread = new DismissThread();
   private class DismissThread implements Runnable {
      public void run() {
   protected boolean navigationClick(int status, int time) {
      return true;
   protected boolean navigationUnclick(int status, int time) {
      return false;
   protected boolean navigationMovement(int dx, int dy, int status, int time) {
      return false;
   public static class SplashScreenListener implements
      KeyListener {
      private SplashScreen screen;
      public boolean keyChar(char key, int status, int time) {
         //intercept the ESC and MENU key - exit the splash screen
         boolean retval = false;
         switch (key) {
            case Characters.CONTROL_MENU:
            case Characters.ESCAPE:
            retval = true;
         return retval;
      public boolean keyDown(int keycode, int time) {
         return false;
      public boolean keyRepeat(int keycode, int time) {
         return false;
      public boolean keyStatus(int keycode, int time) {
         return false;
      public boolean keyUp(int keycode, int time) {
         return false;
      public SplashScreenListener(SplashScreen splash) {
         screen = splash;

There are still errors in the
private static final Bitmap_bitmap
this.add(new BitmapField (_bitmap));
And the SplashScreenListener lines...

Pls help... Tnx in advance
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Splash Screen code error

I presume that you have based you code on this KB article.




This code is intended to go in a separate source file called SplashScreen.java.


The first screen you push is the SplashScreen, not your own screen and the trick is that you pass in the screen you want to display second.


So in your Applications constructor, instead of


pushScreen (new MyappMainScreen ());


you should do something like:


MainScreen firstApplicationScreen = new MyappMainScreen();

SplashScreen splash = new SplashScreen(this, firstApplicationScreen);

pushScreen (splash);


I think restructuring the code will help you sort out where your problems are.