Android Loading Welcome Splash / Spash Screen Example

In android, when we build an application we may need to display a splash screen ( welcome screen ) for users to intimate some thing & do some other process in background ( like fetching data from DB, Parsing XML , etc.. ).

Splash screen is mainly used in Game Applications. Game application may need to show a splash screen that contains App logo, App name & App author of the game to be displayed for few seconds.

Here we are going to see about a simple splash screen example that displays a textview as splash screen & then move to main activity after the splash screen times up.

The output looks similar to


Design a splash screen to display.
Splash.xml file used to show as splash screen. It contains a textview with text as "Splash Screen".

[sourcecode language="xml"]
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="center" android:background="#6B8AAD">
<TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="18sp"
android:textStyle="bold" android:textColor="#fff" android:text="Splash Screen"></TextView>


Splash screen activity is used to show splash . Here we use thread to show splash for particular time and then disappear automatically.

[sourcecode language="java"]
package com.androidpeople.splash;

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

public class SplashScreenActivity extends Activity {

public void onCreate(Bundle savedInstanceState) {
/** set time to splash out */
final int welcomeScreenDisplay = 3000;
/** create a thread to show splash up to splash time */
Thread welcomeThread = new Thread() {

int wait = 0;

public void run() {
try {;
* use while to get the splash time. Use sleep() to increase
* the wait variable for every 100L.
while (wait < welcomeScreenDisplay) {
wait += 100;
} catch (Exception e) {
System.out.println("EXc=" + e);
} finally {
* Called after splash times up. Do some action after splash
* times up. Here we moved to another main activity class
startActivity(new Intent(SplashScreenActivity.this,


This main activity is used to show after the splash times up. From here your Apps start up.

[sourcecode language="java"]
public class MainScreenActivity extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {

TextView textView = new TextView(this);
textView.setText("Main Activity");

That's it..

You can download the full source code from here


Thanks Brayan, The current

Thanks Brayan,

The current activity stops and execute the same activity when you change the phone to landscape mode.The threads get executed twice in this occasion.To stop this we have to manually check and stop the thread when it executes in landscape mode.

Bryan, Look at this link

Look at this link

This describes about how to handle screen orientation in android.

John, First will

First will run, after timer ends will close & then will open.

You can download the source code & check it.

Hong Ann, You are most

Hong Ann,
You are most welcome. Post the code as comment.

Hi Rahul, Replace the

Hi Rahul,
Replace the textview in the splash screen with image view and set the image resource to it.