How to create a simple splash screen

Android Splash screen is the first screen that appears when the application launched. It normally used to display some animations pictures or some introductions about the applications for a limited time.

The App looks Like

Github: https://github.com/rincemathew/splash_screen_in_android

MainActivity.java

public class MainActivity extends AppCompatActivity {


    //set a time of 3 sec
    private static int SPLASH_TIME_OUT = 3000;

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


        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                // This method will be executed once the timer is over
                // Start intent to another activity
                Intent i = new Intent(MainActivity.this, Main2Activity.class);
                startActivity(i);
                // close this activity
                finish();
            }
        }, SPLASH_TIME_OUT);
    }
}

Keep exploring more tutorial from this site. In case of any queries make a comment. Happy coding!!!!

Add a Comment

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