我想使用距离/时间来计算平均速度,但是我不知道如何获得计时器的总秒数。我正在使用这些代码来启动,暂停和停止计时器。我想知道如何获得计时器的总秒数。以我的天文钟为例,我在1:30分钟内暂停我的天文钟,我想获得90秒并将其保存为两倍
public void startChronometer(View v){
if (!running){
chronometer.setBase(SystemClock.elapsedRealtime() - pauseOffset);
chronometer.start();
running = true;
}
}
public void pauseChronometer(View v){
if (running){
chronometer.stop();
pauseOffset = SystemClock.elapsedRealtime() -
chronometer.getBase();
running = false;
}
}
public void resetChronometer(View v){
mDistanceRun.setText(twoDForm.format(mLastdistance) + "Km");
Intent intent = new Intent (MapsActivity.this, fitness_calculator.class);
intent.putExtra("timer", mTime);
intent.putExtra("time", chronometer.getText().toString());
intent.putExtra("distance", mDistanceRun.getText().toString());
intent.putExtra("mDistance" , mLastdistance);
startActivity(intent);}