简体   繁体   中英

Random CountDownTimer on 3 Activity

I am a new user and have a question how to auto roll activity with random countdown time ?

example : ActivityScreen1 display time in 50s-60s -> ActivityScreen2 display time in 30s-40s -> ActivityScreen2 display time in 50s-60s.

前图

Still I want you to learn Android first from some good tutorials. But I can guide you how you can achieve this.

  • You will make a Service . Which will run in background.
  • You will make a Handler in your service. That will call postDelayed() method.

Like this

final Runnable r = new Runnable() {
    public void run() {
        changeActivity(); // make this method & add your logic of checking current activity & setting new
    }
};

handler.postDelayed(r, 1000); // 1000 is millisecond, you will set time here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM