Splash Screen in Android App using Android Studio

Splash Screen is usually shown at start of the application for 2 or 3 seconds of time.

Main purpose of Splash Screen is to show logo and name of the application to user. Sometimes it is also used for fetching required data from remote server before starting the app.

An Android app takes some time to to start up, especially when the app is first launched on a device. A splash screen may display start up progress to the user or to indicate branding.

Latest purpose of splash screen can be found as you can ask for all permissions you are using in application.In all android versions after MARSHMALLOW, you have to request for permission to user. You can learn how to request for permission to user in this demo.

You can implement Splash Screen in many ways in Android. But I have shown easiest and quickest way to implement splash screen.

If you want some animation and cool effects in your splash screen, then visit following tutorial.

Android Animated Splash Screen Tutorial With Source Code  

Following is the output of splash demo:


Implementing Splash Screen In Android

Step 1. Create new project in Android Studio

Step 2. Code for splash

Copy and paste following code in activity_main.xml file:

We have taken an ImageView with full size of screen.

Copy and paste following code in MainActivity.java

You can download this demo by clicking following button.

Introduction of HANDLER Class

The handler class lets you process and send message to other threads, which contain data, and runnable objects that belonging to a thread. A handler will let you execute message objects and runnable objects at a specified time in the future. Each instance of a handler will belong to a single thread only when declared. Runnable objects are those objects that contain commands that will be executed to obtain results in your program.

To explain it to you plainly, a handler be used to execute a thread. It will also allow various threads that make up a program to communicate with each other to prevent conflicts.

Explanation of MainActivity

We have used Handler class of JAVA to implement logic of Splash Screen.

A handler has a method called run().

In this run() method, you can write your required source code or give some instruction to your app.

Here in this example, I have tell my app to open WelcomeActivity.

Now with the help of Handler, you can delayed the execution of the code written in run() method.

You can give time duration in mili seconds to delay the execution of run() method.

In above example, I have taken 2000 mili seconds as delay.

I have used integer variable for this (SPLASH_DISPLAY_LENGTH).

You can change this time duration as per your requirements.

If you want some animation and cool effects in your splash screen, then visit following tutorial.

Android Animated Splash Screen Tutorial With Source Code  

Related link:  Other ways to implement splash screen. 

How to get exact Android example while searching in Google

Visit this page for information.

Cheers and happy coding!

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

6 Responses

  1. Charles says:

    Simple yet quick code to make splash screen in easiest way. Good work!

  2. Peter says:

    Hello,I log on to your blog named “splash screen implementation in app using android studio” regularly.Your writing style is witty, keep up the good work!

  3. Kate Spade says:

    Good tutorials are there on this blog. Really nice work and keep going!

Leave a Reply

Your email address will not be published. Required fields are marked *