BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 02-08-2012, 05:36 AM   #1 (permalink)
New Member
Join Date: Feb 2012
Model: 9800
Carrier: Telkom
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Help linking Splash Screen to App Screen

Please Login to Remove!

Dear all, please help I have Splashscreen code but after build the app, splash screen wont load

here splash screen code
package com.samples.toolkit.ui.test;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.system.GIFEncodedImage;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
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.Graphics;

public class SplashScreen extends MainScreen {
	private static final Bitmap _bitmap = Bitmap.getBitmapResource("amdroid_icon.png");
	private AnimatedGIFField _ourAnimation = null;
	private SplashScreen() {
		super(Field.USE_ALL_HEIGHT | Field.FIELD_LEFT);

		GIFEncodedImage ourAnimation = (GIFEncodedImage) GIFEncodedImage.getEncodedImageResource("cycle.agif");
		_ourAnimation = new AnimatedGIFField(ourAnimation, Field.FIELD_HCENTER);
		this.add(new SpacerField((Display.getHeight() - _bitmap.getHeight() - 20 - (Font.getDefault().getHeight()*2))/2));
		this.add(new BitmapField(_bitmap, BitmapField.HCENTER));
		this.add(new LabelField("Ampacheberry", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER));
		this.add(new SpacerField(10));
		this.add(new SpacerField(10));
		this.add(new LabelField("Connecting...", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER));

   	public static void showScreen(final Runnable runThis) {
   		final SplashScreen thisScreen = new SplashScreen();
   		Thread threadToRun = new Thread() {
   			public void run() {
   				// First, display this screen
   				UiApplication.getUiApplication().invokeLater(new Runnable() {
   					public void run() {
   				// Now run the code that must be executed in the Background
   				try {;
   				} catch (Throwable t) {
   					throw new RuntimeException("Exception detected while waiting: " + t.toString());
   				// Now refresh homescreen, dismiss this screen, and push homescreen if not on stack
               UiApplication.getUiApplication().invokeLater(new Runnable() {
                   	public void run() {
            	    	try {
            	    	} catch(IllegalArgumentException e) {
            	    		/*screen is not on the stack - do nothing*/
           	    		if (!ampacheberry.homeScreen.isDisplayed()) {
   private class SpacerField extends Field {
	    private int _height;

	    public SpacerField(int height) {
	        _height = height;

	    public void layout(int widht, int hieght) {
	        setExtent(Display.getWidth(), _height);

	    public void paint(Graphics g) {
   public class AnimatedGIFField extends BitmapField 
       private GIFEncodedImage _image;     //The image to draw.
       private int _currentFrame;          //The current frame in the animation sequence.
       private AnimatorThread _animatorThread;
       public AnimatedGIFField(GIFEncodedImage image)
           this(image, 0);
       public AnimatedGIFField(GIFEncodedImage image, long style)
           //Call super to setup the field with the specified style.
           //The image is passed in as well for the field to configure its required size.
           super(image.getBitmap(), style);
           //Store the image.
           _image = image;
           //Start the animation thread.
           _animatorThread = new AnimatorThread(this);
       protected void paint(Graphics graphics)
           //Call super.paint.  This will draw the first background frame and handle any required focus drawing.
           //Don't redraw the background if this is the first frame.
           if (_currentFrame != 0)
               //Draw the animation frame.
               graphics.drawImage(_image.getFrameLeft(_currentFrame), _image.getFrameTop(_currentFrame), 
                   _image.getFrameWidth(_currentFrame), _image.getFrameHeight(_currentFrame), _image, _currentFrame, 0, 0);
       //Stop the animation thread when the screen the field is on is
       //popped off of the display stack.
       protected void onUndisplay()
       //A thread to handle the animation.
       private class AnimatorThread extends Thread
           private AnimatedGIFField _theField;
           private boolean _keepGoing = true;      
           private int _totalFrames;               //The total number of frames in the image.
           private int _loopCount;                 //The number of times the animation has looped (completed).
           private int _totalLoops;                //The number of times the animation should loop (set in the image).

           public AnimatorThread(AnimatedGIFField theField)
               _theField = theField;
               _totalFrames = _image.getFrameCount();
               _totalLoops = _image.getIterations();
           public synchronized void stop()
               _keepGoing = false;
           public void run()
                   //Invalidate the field so that it is redrawn.
                   UiApplication.getUiApplication().invokeAndWait(new Runnable() 
                       public void run() 
                       //Sleep for the current frame delay before the next frame is drawn.
                       sleep(_image.getFrameDelay(_currentFrame) * 10);
                   catch (InterruptedException iex)
                   {} //Couldn't sleep.
                   //Increment the frame.
                   if (_currentFrame == _totalFrames)
                       //Reset back to frame 0 if we have reached the end.
                       _currentFrame = 0;
                       //Check if the animation should continue.
                       if (_loopCount == _totalLoops)
                           _keepGoing = false;
My application screen is UIExampleIndexScreen

Any suggest would appreciate
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Help linking Splash Screen to App Screen
Thread Thread Starter Forum Replies Last Post
White screen BB 9700 (Please please help) warrenbuffet BlackBerry Help 8 07-28-2011 05:37 AM
White Screen After Changing (LCD) Please Help shaunyboi BlackBerry Help 1 07-19-2011 08:45 PM
Change app screen wallpaper? ukulele_ninja General 9700 Series Discussion - Bold 2 3 12-06-2009 09:42 PM
"Blank" icons in Zen home screen (and some in app folder) aphr0deity General Legacy Device Discussion 3 04-18-2006 06:14 PM
Sleep Mode - Splash Screen - Screensaver bobbyfester General BlackBerry Discussion 3 10-20-2005 12:19 PM

HP BANANA VIDEO CABLE 5188-8092 CONDUCTOR 30FT, NEW picture1320 feet Polywire With 6 Conductors 400 Meters Partno Systems Single Unit New
1320 feet Polywire With 6 Conductors 400 Meters Partno Systems Single Unit New pictureHubbell Series 16 Brown Single Pole Double Screw Male Camlok 300A 600V HBL400MBN
Hubbell Series 16 Brown Single Pole Double Screw Male Camlok 300A 600V HBL400MBN pictureHubbell HBL300 Male Series Camlocks (Set of 5)
Hubbell HBL300 Male Series Camlocks (Set of 5) picture4/0 Type W General Cable Bulk 2KV Black Extra-Flex
4/0 Type W General Cable Bulk 2KV Black Extra-Flex picture

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.