Splash Screen and navigation

Hello All

This is the first code snippet in the android wherein its expected that you will have the basic knowledge of android ie how it works how to setup a new project what are the layouts activities etc

So to start with I m explaining a simple concept to show the splash screen for some time and then navigate user to the main view

  • Create a class splash.java that extends Activity
  • Create a new layout that holds you splash screen
  • Create a new thread timer that handles the timeout
  • In the finally clause create the Intent for navigation class and start the activity
I know the steps above may be confusing for some users so here comes the entire code for splash .java file
// file Splash.java
package com.bmi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class Splash extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
    	Thread timer=new Thread(){
			public void run() {
				try {
					sleep(5000); // Here is the timeout in my case i use the 5 seconds timeout before navigating to next screen
				catch(InterruptedException e) {
				finally {
					Intent openStartingPoint=new Intent("com.bmi.Calc");
					// Here is the next point where we need to navigate user to 



Dont forget to register your activity in the Android Manifest file else it will throw the Activity not Found Exception


What you think ? Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s