1 year ago

#365956

test-img

T M

Android CountDownTimer won't work in Runnable concurrent task

I have an Android application which has an onClick() handler from a button that starts an asynchronous Runnable task. Partway through, it's supposed to start a new CountDownTimer of 5 seconds, update the text on the page onTick(), and onFinish() update the contents of an AtomicReference<LinkedList<float[]>>.

Code is below for reference, and for context, know that both the Log.i "====..." statements show, but no logs show from in between.

Log.i(TAG, "==== CALIBRATING GYROSCOPE ====");

  isCalibrating = true;
  // CountDownTimer for measurement
  new CountDownTimer(waitTime * 1000, 1000) {
    @Override
    public void onTick(long millisUntilFinished) {
    TextView txt = (TextView)findViewById(R.id.text);
    txt.setText(getString(R.string.calibration_in_progress) + 
               (millisUntilFinished / 1000));
    Log.i(TAG, "Millis until finished: " + millisUntilFinished);
    }

    @Override
    public void onFinish() {
      Log.i(TAG, "Setting current values");
      currentVals.set(gyroVals);
      Log.i(TAG, "Performing file operation");
      performFileOp(0, currentVals.get());
    }
  }.start();

  Log.i(TAG, "==== CALIBRATING ACCELEROMETER ====");

java

android

countdowntimer

java.util.concurrent

atomicreference

0 Answers

Your Answer

Accepted video resources