Skip to content Skip to sidebar Skip to footer

How Do I Show A Splash Screen In Android?

I want to show a splash screen when my app loads up, this is my Java code: ImageView splash = (ImageView) this.findViewById(R.id.splashscreen); splash.postDelayed(new Runnable(){

Solution 1:

You can do as follows:

privatestaticfinalintSPLASH_TIME_OUT=2000;
privatestaticfinalHandlermHandler=newHandler();

@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    mHandler.postDelayed(newRunnable() {

        @Overridepublicvoidrun() {

                startActivity(newIntent(getApplicationContext(), YourActivity.class)); 
                finish();   
        }
    }, SPLASH_TIME_OUT);    
}

Here activity_splash.xml is your splashActivity layout and YourActivity is the Activity you're going to next.

Solution 2:

privateImageView splash;


splash = (ImageView)findViewById(R.id.splashscreen);
newHandler().postDelayed(newRunnable(){
    @Overridepublicvoidrun() {
        splash.setVisibility(View.GONE);
    }
}, 3000);

Try this.

Post a Comment for "How Do I Show A Splash Screen In Android?"