How to call another activity after certain time limit

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

    You could use a Timer and add a TimerTask that is executed after a specific delay.

    Here is a more or less completed example:

    Timer timer = new Timer();
    timer.schedule(new TimerTask() {
    
       public void run() {
    
          //here you can start your Activity B.
    
       }
    
    }, 10000);
    

    The example above executes a new TimerTask in 10 seconds. Inside the TimerTask you can override the run method. In the run method you can start your new activity. The run method is executed after the delay. In this example it is 10'000 milliseconds.

提交回复
热议问题