How to call another activity after certain time limit

后端 未结 4 1524
遥遥无期
遥遥无期 2021-02-06 03:09

How to give time limit for calling one activity to another activity. I want to call another activity (Ex calling A class to B class) by given some time limit. I used alarmManage

4条回答
  •  执念已碎
    2021-02-06 03:39

    Let's hope following example may help.

    Here I have call MainActivity.java after certain time (2 seconds in this example) from MainPage.java

    CODE:

    public class MainPage extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main_page);
            Handler handler=new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    startActivity(new Intent(MainPage.this,MainActivity.class));
                }
            },2000L);
        }
    
    }
    

提交回复
热议问题