Search code examples
javaandroidandroid-activitywaitseconds

Android Studio | Waiting some time before the next Activity shows up (Startscreen)


i want that, when i start my App, a startscreen shows of for 3 seconds and then i want the app to jump automaticly to the next Activity.

I am a beginner at Android Studio so it would be nice if you can explain what it does.

I do not have any code refering to this to show you :(

Thanks a lot


Solution

  • Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
      @Override
      public void run() {
        Intent intent = new Intent(CURRRENTACTIVITY.this, YOURSECONDACTIVITY.class);
        startActivity(intent);
        finish();
      }
    }, 3000);
    

    add this code to the onCreate or onResume method of your first activity after 3sec it will show up your second activity!