how to display an activity automatically after 5 seconds

后端 未结 4 1883
梦如初夏
梦如初夏 2020-12-12 23:29

In my application I have created a splash screen type of thing in android. It should remain for 5 seconds. My problem is that how I display another activity automatically af

4条回答
  •  我在风中等你
    2020-12-13 00:03

    TimerTask task = new TimerTask() {
    
                @Override
                public void run() {
                    Intent intent = new Intent(SplashScreen.this, MainMenu.class);
                    startActivity(intent);
                    finishscreen();
                }
            };
            Timer t = new Timer();
            t.schedule(task, 5000);
    

    and

    private void finishscreen() {
            this.finish();
        }
    

提交回复
热议问题