BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 02-08-2012, 05:36 AM   #1
daynie
New Member
 
Join Date: Feb 2012
Model: 9800
PIN: N/A
Carrier: Telkom
Posts: 1
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
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(_ourAnimation);
		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() {
   						UiApplication.getUiApplication().pushScreen(thisScreen);
   					}
   				});
   
   				// Now run the code that must be executed in the Background
   				try {
   					runThis.run();
   				} catch (Throwable t) {
   					t.printStackTrace();
   					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() {
                   		ampacheberry.redrawHomescreen();
                   		
            	    	try {
            	    		UiApplication.getUiApplication().popScreen(thisScreen);
            	    	} catch(IllegalArgumentException e) {
            	    		/*screen is not on the stack - do nothing*/
            	    	}
                       
           	    		if (!ampacheberry.homeScreen.isDisplayed()) {
           	    			UiApplication.getUiApplication().pushScreen(ampacheberry.homeScreen);
           	    		}
                   }
               });
           }
       };
       threadToRun.start();
   }
	   
	   
   private class SpacerField extends Field {
	    private int _height;

	    public SpacerField(int height) {
	        super(Field.READONLY);
	        _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);
           _animatorThread.start();
       }
       
       protected void paint(Graphics graphics)
       {
           //Call super.paint.  This will draw the first background frame and handle any required focus drawing.
           super.paint(graphics);
           
           //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()
       {
           _animatorThread.stop();
           super.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()
           {
               while(_keepGoing)
               {
                   //Invalidate the field so that it is redrawn.
                   UiApplication.getUiApplication().invokeAndWait(new Runnable() 
                   {
                       public void run() 
                       {
                           _theField.invalidate();                    
                       }
                   });                
                   
                   try
                   {
                       //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.
                   ++_currentFrame;      
                   
                   if (_currentFrame == _totalFrames)
                   {
                       //Reset back to frame 0 if we have reached the end.
                       _currentFrame = 0;
                       
                       ++_loopCount;
                       
                       //Check if the animation should continue.
                       if (_loopCount == _totalLoops)
                       {
                           _keepGoing = false;
                       }
                   }
               }
           }
       }
   }
   
}
My application screen is UIExampleIndexScreen

Any suggest would appreciate
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


Schneider 140CPU65150 Processor/Controller MODICON Quantum NEW picture

Schneider 140CPU65150 Processor/Controller MODICON Quantum NEW

$2835.00



New Sealed Allen-Bradley 1747-L543 SLC 500 5/04 CPU Processor Unit 1747L543 picture

New Sealed Allen-Bradley 1747-L543 SLC 500 5/04 CPU Processor Unit 1747L543

$595.00



Processor SY007 Intel Pentium 100 MHz CPU picture

Processor SY007 Intel Pentium 100 MHz CPU

$11.75



AlphaSmart Neo2 Laptop Word Processor Portable Notebook Pad picture

AlphaSmart Neo2 Laptop Word Processor Portable Notebook Pad

$89.97



New Allen Bradley 1747-L531 SER E SLC 5/03 CPU Processor Unit Module 1747L531 picture

New Allen Bradley 1747-L531 SER E SLC 5/03 CPU Processor Unit Module 1747L531

$317.47



Used & Tested TEKNOR T936IBAAB CPU Single Board picture

Used & Tested TEKNOR T936IBAAB CPU Single Board

$330.91







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