1. What is a Splash Screen In Android?
A splash screen is just an activity in android which the user see it first as soon as the app is launched. Generally a splash screen appears for specific period of times i.e for 3 seconds to 5 Seconds.
2. How Splash Screen Is Different From Other Screens ?
Well there are quite differences in splash screen and other screens in the task that they perform some of them which I think notable are listed below here
- Splash screen is the first screen that the user see if a app has one. But other activities or screens or not the first screen
- Splash Screen runs for specific period of time whereas other screen may not run for specific time
- Splash Screen is simple in nature i.e there will be nothing for user to do in splash screen except just watching it and it also doesn’t contain any buttons generally
- Splash Screen finishes as soon as it moves to next activity and there is no coming back to it until next launch
3. Implementing Splash Screen In Android
There are mainly two ways to create a splash screen in android
- Using Handlers
- Using Threads
Let us discuss them one by one
a. Implementing Splash Screen In Android Using Handler
Sample Code Using Handler
b. Implementing Splash Screen In Android Using Threads
Thread can be called as a light weight process. It will also have a run() but to start a thread we need to call start() on thread object. As soon as a thread starts it will start executing the code inside run() where in Handlers the code written in run() will be started after some delay
Sample Code Using Thread
4. Step By Step Implementation of Splash Screen
Fallow these steps to create splash screen
Step 1 : Setting Up The Project
Create a new android project in android studio and give the name whichever you prefer and create 2 empty activities called SplashScreen and MainActivity (by default MainActivity will created automatically so just create a SplashScreen activity)
Your project structure should look something like in the image
Step 2 : Designing the Splash Screen Activity
Now open the
activity_splash_screen.xml and design it. If you are a complete beginner then you can just paste the code below.
You may get error because of not having the image so just replace it with any other image
Step 3 : Coding Splash Screen
Now open the
SplashScreen.java and paste the code below. I used 1st method that is using handlers. This code will start the MainActivity after 3 seconds
Step 4 : Updating Manifest File
Now we need to make sure that our Splash Screen Activity set as launcher activity in the manifest file and also we don’t want to display the toolbar in Splash Screen we can fix these two things in manifest file.
AndroidManifest.xml and under the Splash Screen activity tag create the intent filter add main action and category as launcher. And remove intent filter tag if MainActivity tag has one with launcher and main tag and set theme to
Your AndroidManifest.xml should look something like this
Step 5 : Run the app
Now our app should run perfectly without any issues. It should look something like this. It may look different on your device since I used different colors and images
5. Final Words
That’s all about the Splash Screen you can download the whole source code from below and work on it. If you have any doubts regarding this feel free to ask them in the comments below.
Bonus : Some Design Tips To Consider While Making Splash Screen
Whenever you are creating Splash Screen or any other screen you must consider material design guidelines. Some of the tips that I can give you for this is
- Don’t make splash screen time too long
- Keep Splash Screen simple. Only use app icon and app name
- If possible add animation to the elements present in splash screen
- You can also use splash screen to make some checks like network availability, some other checks based on that you can move user to different screens
For More design tips visit Material Design Guidelines for Launch Screen
Project Source Code
You can download the source code by clicking this button