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

后端 未结 7 719
感动是毒
感动是毒 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:52

    runOnUiThread(new Runnable() {
            @Override
            public void run() {
                new Handler().postDelayed(new Runnable(){
                    @Override
                    public void run() {
                        Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                        startActivity(intent);
                    }
                }, 4000);
            }
        });
    

提交回复
热议问题