I need a splash screen for my application. Tried creating an activity having the image for my splash screen; and tried using for loop and the Timer class for introducing a t
The simplest way I do for my every project is looks like this:
public class SplashActivity extends Activity {
protected boolean active = true;
protected int splashTime = 1000;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
Thread splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while(active && (waited < splashTime)) {
sleep(100);
if(active) {
waited += 100;
}
}
} catch(InterruptedException e) {
// do nothing
} finally {
finish();
// Start your Activity here
}
}
};
splashTread.start();
}
//...