How to Create a splash screen on android


Create a class called: Splash then paste this code into the flowing class
public class Splash extends Activity
{
    boolean flag = false;
    Runnable runnable;
    Handler handler;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        runnable = new Runnable() {
            @Override
            public void run() {
                if (!flag) {
                    final Intent mainIntent = new Intent(Splash.this, MainActivity.class);
                    Splash.this.startActivity(mainIntent);
                    Splash.this.finish();
                }
            }
        };
        handler = new Handler();
        handler.postDelayed(runnable, 5000);

    }

    @Override
    protected void onPause() {
        super.onPause();
        flag = true;
        handler.removeCallbacks(runnable);
    }

    @Override
    protected void onRestart() {
        super.onRestart();

        flag = false;
        handler.postDelayed(runnable, 1-1);
    }
}

change the replace your main class by ".Splash" (the name of class we just created) then declare a new activity with the name of de fault class you just created
  
            
                

                
            
        
        
finally create your activity_splash layout in the layout folder
   




    
 
pegas7team Web Developer

Morbi aliquam fringilla nisl. Pellentesque eleifend condimentum tellus, vel vulputate tortor malesuada sit amet. Aliquam vel vestibulum metus. Aenean ut mi aucto.