Android 2.2 用のクロノメーター / カウントダウン タイマー アプリを設計中ですが、ボタンを 1 回押すだけでクロノメーターとタイマーの両方を同時に開始したいと考えています。したがって、理想的には、クロノメーターとタイマーの両方の秒 (時間) を同じインスタンスで変更したいと思います。(クロノメーターがカウントアップしていても、タイマーはカウントダウンします)。Android が提供するクロノメーターとタイマー機能を使用しているので、ユーザーが [開始] ボタンを押したときに次のコードを記述しました。
private boolean mStartPressedOnce = false;
long mTimeWhenStopped = 0;
Chronometer mChronometer;   
MyCounter mCounter;
...
@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.StartButton:
        // Perform some initialization for the chronometer depending
        // on the button press
        if (mStartPressedOnce == false) {
            mChronometer.setBase(SystemClock.elapsedRealtime());
        } else {
            mChronometer.setBase(SystemClock.elapsedRealtime() + mTimeWhenStopped);
        }
        // Perform the initialization for the timer
        mCounter = new MyCount(45000, 1000);
        // Fire up the chronometer  
        mChronometer.start();
        // Fire up the timer
        mCounter.start();
        break;
        case R.id.ResetButton:
            // Reset the chronometer  
            mChronometer.setBase(SystemClock.elapsedRealtime());
            mTimeWhenStopped = 0;
            break;
        case case R.id.StopButton:
            mStartPressedOnce = true;
            // Stop the chronometer 
            mTimeWhenStopped = mChronometer.getBase() - SystemClock.elapsedRealtime();
            mChronometer.stop();
            break;
    }
... 
public class MyCounter extends CountDownTimer {
    @Override
    public MyCount(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
    }
    @Override
    public void onFinish() {        
        // Nothing to do here
    }
    @Override
    public void onTick(long millisUntilFinished) {
        long seconds = (long) (millisUntilFinished / 1000);
        long minutes = (long) ((millisUntilFinished / 1000) / 60);
        long hours = (long) (((millisUntilFinished / 1000) / 60) / 60);
        // Do some formatting to make seconds, minutes and hours look pretty    
        // Update the timer TextView            
       (TextView) findViewById(R.id.CountDownTimerTextView))
           .setText(hours + ":" + minutes + ":" + seconds);
    }
}
クロノメーターとタイマーの秒は最初は同期しているように見えますが、しばらくするとオフになり、両方の 2 番目の更新が異なる時間に発生します。
これを修正するために何ができるか考えていました。私は出会いました-そしてこのスレッドを読みました
複数の AsyncTask を同時に実行する -- 不可能ですか?
設計の変更が必要になる可能性があることは認識していますが、何を行う必要があるか正確にはわかりません。
編集:クロノメーターとタイマーのタイプと、クロノメーターを使用して時間を計算する方法が含まれています-jolivierとnjzk2の提案による