Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
ewbaxter
Posts: 2
Registered: 06-28-2009
Accepted Solution

Splash Screen Not Showing and App Not Starting

[ Edited ]

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.

 

Message Edited by ewbaxter on 06-28-2009 03:24 PM
Please use plain text.
Developer
bikas
Posts: 984
Registered: 02-10-2009

Re: Splash Screen Not Showing and App Not Starting

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


 

 

Please use plain text.
New Developer
ewbaxter
Posts: 2
Registered: 06-28-2009

Re: Splash Screen Not Showing and App Not Starting

Bikas,

 

  Thanks!  Works like a charm!

 

E

Please use plain text.
Developer
bikas
Posts: 984
Registered: 02-10-2009

Re: Splash Screen Not Showing and App Not Starting

You are welcome. :smileyhappy:
Please use plain text.
Developer
Nadirfirfire
Posts: 192
Registered: 01-12-2010
My Carrier: ZAIN

Re: Splash Screen Not Showing and App Not Starting

 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

Please use plain text.
Contributor
JideFash
Posts: 46
Registered: 05-03-2011
My Carrier: Vodafone

Re: Splash Screen Not Showing and App Not Starting

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();

}

}

Please use plain text.
New Contributor
daynie
Posts: 8
Registered: 02-06-2012
My Carrier: XL

Re: Splash Screen Not Showing and App Not Starting

Please after I apply call function for splash screen, error show below ... thanks

 

Please use plain text.
Developer
paulkayuk
Posts: 116
Registered: 04-30-2010
My Carrier: T-Mobile

Re: Splash Screen Not Showing and App Not Starting

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.

Please use plain text.
New Contributor
daynie
Posts: 8
Registered: 02-06-2012
My Carrier: XL

Re: Splash Screen Not Showing and App Not Starting

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(dThread);
		}   
	}   
	
	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;      
		}
		
		
	}
}

 

Please use plain text.