waa1990 waa1990 - 1 year ago 93
Java Question

how do i show a splash screen only when the activity starts up not when it is resumed?

i want the spash screen to only show when the app has been compltely destroyed not when it is running in the background and resumed

Answer Source

A very simple method:

Main Activity is only a splash screen. This Activity is shown while a timer starts that elapses for say 4 seconds.

When 4 seconds hits, the splash screen activity is destroyed and the Main Application Activity is started.

Voila, you now have a splash screen that will never be shown, except when you first start the application.

public class SplashScreen extends Activity {

    public void onCreate(Bundle savedInstanceState) {

        Thread t = new Thread() {
            public void run() {
                try {
                    int time = 0;
                    while (time < 4000) {
                       time += 100;
                catch (InterruptedException e) {
                    // do nothing
                finally {
                    Intent i = new Intent(SplashScreen.this, MainApplication.class);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download