Android Countdowntimer在可运行的并发任务中赢得了工作

发布于 2025-01-18 13:16:56 字数 1110 浏览 2 评论 0原文

我有一个Android应用程序,该应用程序在一个按钮中具有onclick()处理程序,该按钮启动了异步运行任务。整个过程中,应该启动一个新的CountDownTimer 5秒钟,更新页面上的文本ontick()onfinish() atomicReference< linkedlist< float []>>的内容。

代码在下面供参考,对于上下文,都知道log.i“ === ...”语句显示,但没有从中间显示logs。

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 ====");

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 ====");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文