How to Create Welcome Screen in Android Studio 2.1.2 Tutorial

A Welcome screen (Splash screen) is must needed for each and every android apps which the developers need them pretty awesome! means the splash screen in android apps have high significance in terms of achieving users best opinions.

This time, we're adding Splash screen to our android app.

Watch the tutorial from our own YouTube Channel

Manually adding splash screen to your android app? Here we go!

You can also get the complete source code from below

We start by adding the required codes to Main Activity

MainActivity.java
 package com.sabithpkcmnr.splashscreen;  

import android.content.Intent;
import android.os.Handler;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
private static int WELCOME_TIMEOUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent welcome = new Intent(MainActivity.this, SecondActivity.class);
startActivity(welcome);
finish();
}
},WELCOME_TIMEOUT);

}
}


Here we have added WELCOME_TIMEOUT = 3000; which let the app starts SecondActivity after 3 seconds

SecondActivity.java
We have done nothing with this, so it's not necessary

activity_main.xml & second_activity.xml
As same as above mentioned SecondActivity.java, nothing is to be added or removed in this case, So we're leaving those. The second_activity.xml's name varies as you given when you create a layout.


Finally, you have done!

Thanks for your time. Have a great day.


No comments:

Powered by Blogger.