Add a splash screen to the BlackBerry Hybrid Web Container.
The splash screen is the first screen you see in the Hybrid Web Container. The related comment tag is BLACKBERRY_CUSTOMIZATION_POINT_SPLASHSCREEN.
return SplashScreen.class;
package com.sybase.hwc;
import net.rim.device.api.system .*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import java.util.*;
/**
* A simple splash screen.
*/
public class SplashScreen extends MainScreen
{
private Timer timer = new Timer();
public SplashScreen()
{
setTitle("Splash Screen");
add( new LabelField( "Splash" ) );
addKeyListener( new SplashScreenListener( this ) );
// Dismiss the splash screen after 5 seconds.
timer.schedule( new CountDown(), 5000 );
UiApplication.getUiApplication().pushScreen( this );
UiApplication.getUiApplication().requestForeground();
}
public void dismiss()
{
timer.cancel();
UiApplication.getUiApplication().popScreen( this );
}
private class CountDown extends TimerTask
{
public
void run()
{
UiApplication.getUiApplication().invokeLater( new DismissThread() );
}
}
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;
}
private static class SplashScreenListener implements KeyListener
{
private SplashScreen screen;
public SplashScreenListener( SplashScreen splash )
{
screen = splash;
}
public boolean keyChar( char key, int status,
int time )
{
// Quit the splash screen if ESC or MENU
key pressed.
switch ( key )
{
case
Characters.CONTROL_MENU:
case Characters.ESCAPE:
screen.dismiss();
return true;
}
return false;
}
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;
}
}
}