Search code examples
javaandroidparallel-processingcountdown

Prevent Android function call from running before its predecessor completes?


I am running a main function that calls three others in succession like this:

public void test() {
   countdown(); 
   secondMethod(); 
   lastMethod(); 
}

But before my call from within countdown() ie intermediateFunction() is compete, secondMethod runs. Countdown contains a timer that calls another function before it completes, like this:

public void countdown() {
    new CountDownTIme(3000, 1000) {
         public void onTick(long millisUntilFinished) {
                text.setText( Long.toString(millisUntilFinished / 1000);
         }
    }
    public void onFinish() {
         text.setText(" "); 
         intermediateFunction(); 
    } 
 }.start(); 
}

How can I get it to run in succession from countdown->intermediate->secondMethod->etc.?


Solution

  • Call secondMethod() from onFinish() of countdown().