How to start a different activity with some delay after pressing a button in android?

后端 未结 7 728
感动是毒
感动是毒 2020-12-30 04:14

I want that a new activity should start with some delay on pressing a button. Is it possible to do that , and whats the procedure.

7条回答
  •  情歌与酒
    2020-12-30 04:28

    Use This code

    new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                final Intent mainIntent = new Intent(CurrentActivity.this, SecondActivity.class);
                LaunchActivity.this.startActivity(mainIntent);
                LaunchActivity.this.finish();
            }
        }, 4000);
    

提交回复
热议问题