In my app I am taking answers from a user for a mathematical game. Once the answer is entered the next question is displayed etc. Currently if the question is answered and a letter or a blank answer is entered by mistake the app crashes. I want for the app to just not take the user's answer if it is invalid and to keep displaying the question until a valid answer (number) is given.
Current code:
// sets text view equal to what is entered in editText
final String entry = answer.getText().toString();
// convert from string value to int
int a = Integer.parseInt(entry); //
// setting the user answer equal to the correct part of results array
results[questionNumber - 1] = a;
// If user answer is equal to correct answer then increase score
if (a == correctAnswer[questionNumber - 1]) {
score++;
correctNoise.start();
imageRandom.setImageResource(R.drawable.thumbsup);
}else{
incorrectNoise.start();
imageRandom.setImageResource(R.drawable.thumbsdown);
}