Tuesday, December 9, 2014

Splash Screen in Android

What is Splash Screen?

when application start then first screen,called   "Splash Screen"  also called " launching screen ." it may be logo or introduction of application and show for few seconds.

     

 int splashTime=5*1000;// 5 second


 Thread splashThread=new Thread(new Runnable() {


@Override

public void run() {

// TODO Auto-generated method stub
try {
Thread.sleep(splashTime);  // sleep for 5 seconds
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// after 5 seconds it will go to next screen
finish(); // never back to splash Screen
Intent i=new Intent(SplashScreen.this, HomeActivity.class);
startActivity(i);
}
});

                      splashThread.start();


Alternate Way:

   new android.os.Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
             finish(); // never back to splash Screen
Intent i=new Intent(SplashScreen.this, HomeActivity.class);
startActivity(i);
            }

        }, splashTime);


Splash Screen Android
Splash Screen Android
visit here more tutorials:    http://www.invokecode.com 
Thank You !!

No comments :

Post a Comment