How to call another activity after certain time limit

后端 未结 4 1527
遥遥无期
遥遥无期 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:52

    This can also be done using android CountDownTimer class.

    See this example for a 3 second delay.

    new CountDownTimer(3000, 1000) {
        public void onFinish() {
             Intent startActivity = new Intent(ThisActivity.this,ActivityToStart.class);
             startActivity(startActivity);
            finish();
        }
    
        public void onTick(long millisUntilFinished) {
        }
    
    }.start();
    

    You may also need to define your parent activity in AndroidManifest.xml file,

    
    
          
          
    
    

提交回复
热议问题