Ive been looking to see a method to see if a CountDownTimer is running or not, but I cant find a way to, any help would be greatly appreciated
if (position =
Check if the CountDownTimer is Running and also if the app is running in the background.
@Override
protected void onCreate(Bundle savedInstanceState) {
...
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myButton.setText("Button clicked");
countDownTimer = new CountDownTimer( 3000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
//After turning the Smartphone the follow both methods do not work anymore
if (!runningBackground) {
myButton.setText("Calc: " + millisUntilFinished / 1000);
myTextView.setText("Calc: " + millisUntilFinished / 1000);
}
}
@Override
public void onFinish() {
if (!runningBackground) {
//Do something
}
mTextMessage.setText("DONE");
runningBackground = false;
running = false;
}
};
//timer started
countDownTimer.start();
running = true;
}
});
}
@Override
protected void onResume() {
super.onResume();
runningBackground = false;
}
@Override
protected void onPause() {
runningBackground = true;
super.onPause();
}