06-28-2009 01:57 PM - last edited on 06-28-2009 03:24 PM
Hello and thanks in advance.
I'm trying to build a splash screen that displays a logo for 5 seconds then returns to the main application, but the application neither shows the splash screen nor starts the main thread. I reviewed the sample Splash Screen code and tried to emulate it closely. Template code is shown below.
import java.util.Timer;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FocusChangeListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.container.MainScreen;
public class Test extends UiApplication {
public static void main(String[] args) {
Test app = new Test();
app.enterEventDispatcher();
}
public Test() {
SplashScreen screen = new SplashScreen();
pushScreen(screen);
}
public class TestScreen extends MainScreen implements FocusChangeListener{
public void focusChanged(Field field, int eventType) {
}
}
}
class SplashScreen extends MainScreen {
private UiApplication application;
private MainScreen next;
private static final Bitmap _bitmap = Bitmap.getBitmapResource("resource/logo.png");
private Timer timer = new Timer();
public SplashScreen(){
Test tmpTest = new Test();
Test.TestScreen tmpScreen = tmpTest.new TestScreen();
this.next = tmpScreen;
this.add(new BitmapField(_bitmap));
}
public void dismiss() {
timer.schedule(new CountDown(), 5000);
timer.cancel();
application.popScreen(this);
application.pushScreen(next);
}
}
The simulator is the Curve 8330 and the api is 4.5.
Any help would be great.
Best Regards and Thanks again.
Solved! Go to Solution.
06-28-2009 02:54 PM
1. The implementation of your SplashScreen() class is not correct.
I modified your SplashScreen() this way:
class SplashScreen extends MainScreen { private UiApplication application; private MainScreen next; private static final Bitmap _bitmap = Bitmap.getBitmapResource("resource/logo.png"); private Timer timer = new Timer(); public SplashScreen(UiApplication application, MainScreen next) { this.application = application; this.next = next; this.add(new BitmapField(_bitmap)); timer.schedule(new CountDown(), 5000);
//show this splash screen
application.pushScreen(this); } public void dismiss() { timer.cancel(); application.popScreen(this); application.pushScreen(next); } private class CountDown extends TimerTask { public void run() { DismissThread dThread = new DismissThread(); application.invokeLater(dThread); } } private class DismissThread implements Runnable { public void run() { dismiss(); } } }
2. And also you have to call SplashScreen from the main class in the following way:
public Test() {
//the screen that will show after splash screen
TestScreen nextScreen = new TestScreen();
new SplashScreens(this,nextScreen); }
Regards
Bikas
06-28-2009 03:38 PM
Bikas,
Thanks! Works like a charm!
E
06-28-2009 03:39 PM
01-20-2010 01:24 AM
public Test()
{
//the screen that will show after splash screen
TestScreen nextScreen = new TestScreen();
new SplashScreens(this,nextScreen);
}
i implemented this like this way...
in my main method
class ZeoApp extends UiApplication
{
ZeoApp()
{
LoginPage loginScreen= new LoginPage();
//HomePage homeScreen = new HomePage();
//this.pushScreen(homeScreen);
// this.pushScreen(loginScreen);
new SplashScreen(this,loginScreen);
}
public static void main(String[] args)
{
ZeoApp myApp = new ZeoApp();
myApp.enterEventDispatcher();
}
}
can you please tell me where iam going wrong...
rgds
Nadir
05-24-2011 12:50 PM
This is how your main class should be
public class StreamingPlayerSample extends UiApplication{
MainScreen mainScreen;
public StreamingPlayerSample() {
PlayerScreen playerScreen = new PlayerScreen();
addKeyListener(playerScreen);
new SplashScreen(this, playerScreen);
//pushScreen(playerScreen);
}
public static void main(String[] args) {
StreamingPlayerSample app = new StreamingPlayerSample();
app.enterEventDispatcher();
}
}
02-09-2012 05:02 AM
Please after I apply call function for splash screen, error show below ... thanks

02-09-2012 07:27 AM
The first error is exactly what it says, you have no constructor for your spalsh screen that takes 2 UIExampleIndexScreens as parameters. Show us you SplashSCreen Constructor.
The second error is exactly what it says your super constructor call must be the first statement in your constructor, i.e. it must be before the preceding 2 lines.
These are basics, you must start to read, think about, and understand the error messages you are struggling with.
02-09-2012 10:23 PM
splash screen coe below
package com.samples.toolkit.ui.test; import java.util.Timer; import java.util.TimerTask; import javax.microedition.lcdui.Graphics; import net.rim.device.api.system.Bitmap; import net.rim.device.api.system.Characters; import net.rim.device.api.system.KeyListener; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.Manager; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.BitmapField; import net.rim.device.api.ui.component.LabelField; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.ui.container.VerticalFieldManager; import net.rim.device.api.system.Display; import net.rim.device.api.ui.Screen; public class SplashScreen extends MainScreen { VerticalFieldManager _fieldManagerMiddle; BitmapField _bitmap; Bitmap _DAFLogo; private Timer timer = new Timer(); public SplashScreenMASTER() { super(); _fieldManagerMiddle = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Field.USE_ALL_WIDTH | Field.FIELD_HCENTER); _DAFLogo = Bitmap.getBitmapResource("rpm-small.png"); _bitmap = new BitmapField(_DAFLogo); _bitmap.setSpace(Display.getHeight()/2 - _DAFLogo.getWidth()/2, Display.getWidth()/2 - _DAFLogo.getHeight()/2); _fieldManagerMiddle.add(_bitmap); add(_fieldManagerMiddle); SplashScreenListener listener = new SplashScreenListener(this); this.addKeyListener((KeyListener) listener); timer.schedule(new CountDown(), 10000); //UiApplication.getUiApplication().pushScreen(this ); } public void dismiss() { timer.cancel(); UiApplication.getUiApplication().popScreen(this); UiApplication.getUiApplication().pushScreen(new WelcomeScreen(_fieldManagerMiddle)); } private class CountDown extends TimerTask { public void run() { DismissThread dThread = new DismissThread(); UiApplication.getUiApplication().invokeLater(dThre ad); } } private class DismissThread implements Runnable { public void run() { dismiss(); } } protected boolean navigationClick(int status, int time) { dismiss(); 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 SplashScreenMASTER 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: 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(SplashScreenMASTER splash) { screen = splash; } } }