i make this a Timer that makes me check the correct answer every time user compose a word so it's working if user submit correct answer but when i made else test for wrong answer it couldn't work and app crashed,
plz help me i want to check if answer wrong
//to check the whole answer
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
//answer button get text to string
final StringBuilder str = new StringBuilder();
for (int i = 0; i < btnanswer.length; i++) {
str.append(String.valueOf(btnanswer[i].getText()));
Log.d("asdf", "run: " + str);
gamefinished = true;
}
//check answer button with the button
if (answer.toLowerCase().equals(String.valueOf(str).toLowerCase())) {
startActivity(new
Intent(MainActivity.this,SecondActivity.class));
timer.cancel();
}
}
}, 0, 10);