timeLeft is working for playing music file, but how to work with onResume? So I can pause the activity, then resume with left timer.
Here is my code:
public void countdownTimer () {
final TextView mTextField = (TextView)findViewById(R.id.timer);
Count = new CountDownTimer(TIMER, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("" +(millisUntilFinished / 60000));
long timeLeft = millisUntilFinished / 1000;
if(timeLeft <= 4 && timeLeft >=2 && tgbutton.isChecked())
{
mSoundPool.play(sixthMusicFile, 1f, 1f, 1, 0, 1f);
}
if(timeLeft <= 1 && tgbutton.isChecked())
{
mSoundPool.play(seventhMusicFile, 1f, 1f, 1, 0, 1f);
vibrate();
}
}
public void onFinish() {
Count.setText("done!");
}
}.start();
}
EDITED: Finally, I got some answer. Working code here: Android CountDown Timer with Pause, Resume and Cancel button. Many thanks to everybody who help me before.