Open In App

Android | Creating a Splash Screen

Last Updated : 19 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

A splash screen is mostly the first screen of the app when it is opened. It is a constant screen which appears for a specific amount of time, generally shows for the first time when the app is launched. The Splash screen is used to display some basic introductory information such as the company logo, content, etc just before the app loads completely.

Creating Splash screen using handler in Android

Here we created two activities MainActivity showing the Splash Screen and SecondActivity in order to switch from MainActivity to SecondActivity. The main program is written in MainActivity, you can change activities as per your need.

  • To remove the ActionBar, you need to make following changes in your styles.xml file.
style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"
...
  • Use colors which is suitable for your application.
  • No need to make any changes in your manifest file.

MainActivity.java

Java




package com.example.hp.splashscreen;
 
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Handler;
import android.view.WindowManager;
 
public class MainActivity extends AppCompatActivity {
    private static final int SPLASH_SCREEN_TIME_OUT = 2000; // After completion of 2000 ms, the next activity will get started.
     
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        // This method is used so that your splash activity can cover the entire screen.
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
 
        setContentView(R.layout.activity_main); // this will bind your MainActivity.class file with activity_main.
         
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                // Intent is used to switch from one activity to another.
                Intent i = new Intent(MainActivity.this, SecondActivity.class);
                startActivity(i); // invoke the SecondActivity.
                finish(); // the current activity will get finished.
            }
        }, SPLASH_SCREEN_TIME_OUT);
    }
}




Similar Reads

Correct Way to Add a Splash Screen in Android
Google previously advised against utilizing a Splash Screen for Android Applications. It was pointless. Then, when they released the Material Design Specifications, several of us noticed that the Splash Screen had been renamed Launch Screen. Ideal for displaying your brand. So, what is the distinction between a terrible LaunchScreen and a good Laun
3 min read
How to Create a Splash Screen With Layer-List in Android?
Splash Screen is an initial screen that gets displayed on the app's launch. So to either display your logo or to display your app's name on the startup of the screen. Similar to what WhatsApp or Instagram apps do on their launch. They display a simple logo of their app. Now, here comes the problem, To do this you make a launcher activity, and in th
3 min read
Dynamic Splash Screen in Android
A Dynamic Splash screen is a more personalized image or graphic that is displayed when an application is loaded or launched. Dynamic Splash Screen consists of animation or moving graphics. It appears for a fraction of a second. It creates a sense of anticipation or excitement for the user and helps organizations with branding and establishing ident
3 min read
Splash Screen in Android
A splash screen is mostly the first screen of the app when it is opened. It is a constant screen that appears for a specific amount of time and generally shows for the first time when the app is launched. Splash screen is used to display some basic introductory information such as the company logo, content, etc just before the app loads completely.
4 min read
Creating Multiple Screen Applications in Android
This article shows how to create an android application to move from one activity to another. Below are the steps for Creating a Simple Android Application to move from one activity to another activity. Step By Step ImplementationStep 1: Create a New Project in Android StudioTo create a new project in Android Studio please refer to How to Create/St
9 min read
How to Get Screen Dimensions as Pixel in Android?
Many times while building an android application we want to place elements dynamically within our android application. We can place these elements by specifying their position relative to the screen dimensions within the android application. For this, we will need to get device screen dimensions. In this article, we will take a look at How to get s
3 min read
How to scale different Views to all screen sizes in Android Studio?
In this article, it is shown how to change the size of View in Android App Development (like TextView, etc), so that they can modify the content that is displayed on the screen. Note: For this article, XML visualizer instead of Android Studio. Below are the various methods to change the size of Views in Android: Hard-coding the values in dp (densit
4 min read
Screen Orientations in Android with Examples
Screen Orientation, also known as screen rotation, is the attribute of activity element in android. When screen orientation change from one state to other, it is also known as configuration change. States of Screen orientation There are various possible screen orientation states for any android application, such as: ActivityInfo.SCREEN_ORIENTATION_
3 min read
Locking Screen Orientation in Android
If there is a scenario where you need your entire application to be in portrait mode or landscape mode or one of the Activity should be in portrait mode and all the other activities should be set at auto screen orientation, then here this article makes you do that in simple steps. So in this article, we are going to learn the following two things.
4 min read
How to Keep the Device Screen On in Android?
In Android it's seen that screen timeout will be set for 30 seconds or it is set by the user manually in system settings, to avoid battery drain. But there are cases where applications like stopwatch, document reader applications, games, etc, need the screen to be always awake. In this article its been demonstrated, how to keep the device screen aw
4 min read
Article Tags :
Practice Tags :