Thursday, May 12, 2016

Android Splash Screen using Android Studio

Most of the Android apps uses splash screen before launching their application activity. You can see that with most popular apps such as Skype, Facebook, Dropbox etc.

While I was developing an Android APP POC for one of my customer, the requirement was to create a splash screen with their logo which stays on the screen for 3 seconds. It can be done very easily with the below steps.

First we have to create a new project in the Android studio :
1. Click on File -> New Project
2.     Mention the application Name And Minimum SDK, Click on Next
3.     Select Blank Activity and Click Next Button
4.     Click on Finish

This create the android application with blank activity. Now we will add the Splash screen at the start this application.
First Create a layout to display the Splash screen. We call it as splash.xml.

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android=""

We have to copy the splash_image.jpg image file to drawable folder. This is the image which is going to be shown in the splash screen.

Now create a activity which sets this splash content view. This activity we call it as Put the below code to this class   
package marutsoft.vehicledata;
import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.widget.ImageView;
 * Created by Karjol G T on 11-05-2016.
public class SplashScreen extends Activity {
    protected int _splashTime = 3000;
     private Thread splashThread;
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        Display display = getWindowManager().getDefaultDisplay();
        Thread timerThread = new Thread(){
            public void run(){
                }catch(InterruptedException e){
                    Intent intent = 
                    new Intent(SplashScreen.this,MainActivity.class);
    protected void onPause() {
        // TODO Auto-generated method stub
We have mentioned the sleep for 3000 ms that’s 3 seconds. Here Once the splash screen is done it invokes MainActivity.class.

Now we have to include the splash activity to Manifest and we have to make it as a launcher activity to start the application with this activity. You need to add the below code to the AndroidManifest .xml file. 

            android:label="@string/app_name" >
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>

Now Run this Android application to check the Splash screen running at the beginning of the application.

That’s it. Happy Coding..

No comments: