0
public class SplashScreen extends Activity {
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_screen);

    try {
        Thread.sleep(5000);
    } catch(InterruptedException ex) {
        Thread.currentThread().interrupt();
    }

    Intent LoginActivity = new Intent(SplashScreen.this, LoginActivity.class);
    startActivity(LoginActivity);
    finish();
}

}

with activity_splash_screen is layout of splash screen. My app has displayed white screen instead of my splash-image.

when I do not set the next action LoginActivity my splash-image comes back!

public class SplashScreen extends Activity {
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_screen);

    try {
        Thread.sleep(5000);
    } catch(InterruptedException ex) {
        Thread.currentThread().interrupt();
    }

    // Intent LoginActivity = new Intent(SplashScreen.this, LoginActivity.class);
    // startActivity(LoginActivity);
    finish();
}

}

1 Answers1

1

You shouldn't call Thread.sleep() on your main thread. Try this instead:

        new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            Intent LoginActivity = new Intent(SplashScreen.this, LoginActivity.class);
            startActivity(LoginActivity);
            finish();
        }
    }, 5000);
questioner
  • 2,283
  • 3
  • 26
  • 35