Android Countdowntimer在可运行的并发任务中赢得了工作
我有一个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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论