Simulator Screenshots

Splash screen - Android Example

DOWNLOAD SOURCE CODE
 

Splash screen is an activity that will show for set time when your app is starting and after set time period redirect to application main scre

 

Example :

Lets splash screen show set time is 15 sec then in mean time when splash screen showing you can do these tasks...

   1. You can download resources(images) from webserver to your phone.
   2. You can make server call and get data from server.
   3. Get data from network and save in database.

   4. Show something about your app/company/brand on Splash screen.

 

 

Project Structure :

 

Splash_screen_project_sketch

 

 

File : src/MainSplashScreen.java

 

Showing two methods to create splash screen ....
METHOD 1: Create a thread and set time to sleep after that redirect to main app screen.
METHOD 2: Set time to handler and call Handler().postDelayed , it will call run method of runnable after set time and redirect to main app screen.

 


package com.androidexample.splashscreen;

import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;

public class MainSplashScreen extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_splash_screen);
		
// METHOD 1		
		
         /****** Create Thread that will sleep for 5 seconds *************/  		
		Thread background = new Thread() {
			public void run() {
				
				try {
					// Thread will sleep for 5 seconds
					sleep(5*1000);
					
					// After 5 seconds redirect to another intent
				    Intent i=new Intent(getBaseContext(),FirstScreen.class);
					startActivity(i);
					
					//Remove activity
					finish();
					
				} catch (Exception e) {
				
				}
			}
		};
		
		// start thread
		background.start();
		
//METHOD 2	
		
		/*
		new Handler().postDelayed(new Runnable() {
			 
            // Using handler with postDelayed called runnable run method
 
            @Override
            public void run() {
                Intent i = new Intent(MainSplashScreen.this, FirstScreen.class);
                startActivity(i);
 
                // close this activity
                finish();
            }
        }, 5*1000); // wait for 5 seconds
		*/
	}
	
	@Override
    protected void onDestroy() {
		
        super.onDestroy();
        
    }
}


 

File : src/FirstScreen.java

 

Splash screen will redirect to this screen.

 


package com.androidexample.splashscreen;

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

public class FirstScreen extends Activity {
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.firstscreen); 
		
	} 
	
	@Override
    protected void onDestroy() {
		
        super.onDestroy();
        
    }
}

 

Some Experts says :

   1. A splash screen prevents the user from using the application.
   2. Most of the time, it is not necessary.
   3. Adding once viewed images increase the size of your APKs.

   4. Users don’t care about branding at launch time.

 

Share this: