How to implement Splash Screen Activity in Android Studio Using JAVA

Hemant Patel
3 min readMar 11, 2021

--

Android Splash Screen is the first screen visible to the user when the application’s launched. The splash screen is one of the most vital screens in the application since it’s the user’s first experience with the application.

Splash screens are used to display some animations (typically of the application logo) and illustrations while some data for the next screens are fetched

Step 1: Create New Project

Click on the Create New Project button

Step 2: Choose empty Activity

Step 3: Write App Name and Choose Language.

write your app name whatever you want. in this implementation, I am writing “Splash Screen Demo”. choose the JAVA language in the language section.

after that click the Finish button.

Step 4: Add new Activity for Splash Screen.

Right-click on App then follow this New → Activity → Empty Activity

Step 5: Write the name of Splash Screen Activity.

you can write whatever, It is fully on you. after that click on the Finish button.

Step 6: Make Splash Screen Activity as Launcher Activity.

By default Main Activity is Launcher Activity. It means When we launch our app then Main Activity opens first. But we want that splash screen activity to show first.

For making this we will change some lines of code in the AndroidManifext.xml file. like this,

Code :

<activity android:name=".SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Step 7: Write Logic in SplashScreenActivity.java

we want that when we launch our splash screen, It shows for 4 Sec after that redirect to our Main Activity. it is possible by using Runnable Handler Methods. It triggers after wanted Sec (in here 4 sec ).

you can read all official documentation of Handler and Runnable for more knowledge.

we are using Intent for go main activity from the splash screen activity.

Code:

Handler mHandler;
Runnable mRunnable;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);

mHandler = new Handler();
mRunnable = new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashScreenActivity.this,MainActivity.class);
startActivity(intent);
finish();
}
};

// its trigger runnable after 4000 millisecond.
mHandler.postDelayed(mRunnable,4000);

}

Final Output :

I hope you like this implementation. please share this with your friends and don’t forget to follow me for useful content.

You can DOWNLOAD all source codes of this implementation.

You can connect with me :

Hemant Patel

Android App Developer | UI Designer | Competitive Programmer

Github | Linkedin | Medium | StackOverflow | GeeksforGeeks

--

--

Hemant Patel
Hemant Patel

Written by Hemant Patel

Android App Developer | UI Designer | Competitive Programmer