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
New Contributor
Posts: 3
Registered: ‎08-01-2012
My Device: 9700
My Carrier: Glo Nig

SplashScreen Help!

Hi everyone, SplashScreen refused to work. I followed the sample I got from

http://www.blackberry.com/developers/javaknowledge/userInterface/kpa0206145537.shtml

Here is my code,


package glaxpackage;
import net.rim.device.api.ui.UiApplication;
/**
 * This class extends the UiApplication class, providing a
 * graphical user interface.
 */
public class Glax extends UiApplication
{
    /**
     * Entry point for application
     * @param args Command line arguments (not used)
     */ 
    public static void main(String[] args)
    {
        // Create a new instance of the application and make the currently
        // running thread the application's event dispatch thread.
        Glax theApp = new Glax();       
        theApp.enterEventDispatcher();
    }
    
    /**
     * Creates a new Glax object
     */
    public Glax()
    {        
        // Push a screen onto the UI stack for rendering.
    pushScreen (new SplashScreen());
    }    
}


And SplashScreen



package glaxoopackage;
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.*;
/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public class SplashScreen extends MainScreen
{
private MainScreen next;
private UiApplication application;
private Timer timer = new Timer();
private static final Bitmap _bitmap = Bitmap.getBitmapResource("splash9900.png");
/**
     * Creates a new SplashScreen object
     */
    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);
this.addKeyListener(listener);
timer.schedule(new CountDown(), 5000);
application.pushScreen(this);
    }
    
public void dismiss() {
timer.cancel();
application.popScreen(this);
application.pushScreen(next);
}
    
    /**
* This is used to make sure the SplashScreen exists and
* does not display for ever.
* @author Woods Inc 
*/
private class CountDown extends TimerTask {
public void run() {
DismissThread dThread = new DismissThread();
application.invokeLater (dThread);
}
}
/**
 * Used by the SplashScreenCountDown to exist the SplasScreen.
 * 
 * @author Woods Inc
 */
private  class DismissThread implements Runnable {
public void run() {
dismiss();
}
}
/**
* When user click the navigation then the screen should exist and go to your application main screen
* See net.rim.device.api.ScreennavigationClick(int, int
*/
protected boolean navigationClick(int status, int time){
dismiss();
return true;
}
/*
* Makes sure nothing happens when the navigation senses movement
* @see net.rim.device.api.ui.ScreennavigationMovement(int, int, int, int)
*/
/*
* Makes sure nothing happens when unclick occurs
* @see net.rim.device.api.ui.ScreennavigationUnclick( int, int)
*/
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){
//interpret the Esc and Menu key - exit the splash screen
boolean retval = false;
switch (key){
case Characters.CONTROL_MENU:
case Characters.ESCAPE:
screen.dismiss();
retval = true;
break;
}
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;
}
}
}
   


* I have also tried
pushScreen (new SplashScreen(null, null));

But nothing seems to work.

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

Re: SplashScreen Help!

The link you gave didn't work for me, so here it is again:

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

 

Here is an explanation for the first parameter you need to pass.

http://supportforums.blackberry.com/t5/Java-Development/A-question-about-RIM-splashSreen-example/m-p...

 

The second parameter is the screen you want the splash screen to display once the time is over.  Your sample does not create one, so the SplashScreen processing probably fails at that point.

 

Have another look at the code with this information. 

 

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

Re: SplashScreen Help!

Thanks Peter Strange! Atleast there are no errors indicating. I tried running it on a sim but i get Uncaught execption, error 104 . I did exactly as you instructed extending a screen to display after splash screen timeout. This is the code replacement in the pushScreen

 
HomeScreen homePage = new HomeScreen();
SplashScreen splash = new SplashScreen(this, homePage);
pushScreen (splash);

The homeScreen i extended is just a simple HelloWorld screen

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

Re: SplashScreen Help!

You need to debug the 104.

 

It is actually just a catch all for an error in the java processing.  The easiest way to find this is to debug.  If you are doing this in a Simulator debugging is easy.  If you are doing this on device, this might help:

 

http://supportforums.blackberry.com/t5/Java-Development/How-Do-I-Debug-on-a-Live-Device/ta-p/446842