I want to finish my CountdownTimer on Back button. I know that there a a few similar questions but that doesn´t help me with my problem.
I´ve got the following code in onCreate()
@Override
public void onFinish() {
new CountDownTimer(10000, 550) {
@Override
public void onTick(long millisUntilFinished) {
for(int i = 0; i< arr.size(); i++){
Button aga = arr.get(i);
if(aga.getVisibility() == View.VISIBLE){
aga.setVisibility(View.GONE);
}
}
int zufall = (int) (Math.random()*23);
setNextButton(arr.get(zufall));
}
@Override
public void onFinish() {
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
new CountDownTimer(10000, 350) {
@Override
public void onTick(long millisUntilFinished) {
for(int i = 0; i< arr.size(); i++){
Button aga = arr.get(i);
if(aga.getVisibility() == View.VISIBLE){
aga.setVisibility(View.GONE);
}
}
int zufall = (int) (Math.random()*23);
setNextButton(arr.get(zufall));
System.out.println("HHH");
}
@Override
public void onFinish() {
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
Intent highscore = new Intent (MainActivity.this, Highscore_eintragen.class);
highscore.putExtra("count", count);
startActivity(highscore);
}
}.start();
}
}.start();
}
}.start();
Now what I need is, if the user presses the back button during the CountdownTimer
to finish my activity. Any solutions for that problem?