1
You guys, good night. I need a little help, I have the following code. Because I need to stop Thread when the back button is clicked.
private void timeGame() {
t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
//runOnUiThread
runOnUiThread(new Runnable() {
@SuppressLint("SetTextI18n")
@Override
public void run() {
if (timeCounter > 0){
timeCounter--;
textoTime.setText((Integer.toString((timeCounter))));
}else{
t.cancel();
startActivity(new Intent(QuestionsSolo.this, GameOver.class));
QuestionsSolo.this.finish();
}
}
});
}
}, 1000, 1000);
}
@Override
public void onBackPressed() {
//funcionando, ficou assim.
t.cancel();
startActivity(new Intent(QuestionsSolo.this, TypeFragmentSolo.class));
}
}
No need to put (solved) the Guil question. The fact that you approve an answer means that the question has been resolved. Hug!
– Andrei Coelho
Malz, I didn’t know. Hugs bro. Thanks again. kkk
– GuilDraco