1) Pass a boolean to the getNextQuestion method indicating that time is up.
2) Return a boolean from getNextQuestion indicating if there are more questions.
3) Don't start a new activity from the ResultActivity, simply quit the current one and let it fall back to the previous one. Then, in onResume, reset the timer and game state.
For questions 1 and 2 these updates might help you (note that I haven't actually compiled this so it might be a bit broken);
butNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getNextQuestion(false);
countDownTimer.start();
}
});
@Override
public void onFinish() {
Log.e("Times up","Times up");
if (getNextQuestion(true)) {
countDownTimer.start();
}
}
boolean getNextQuestion(bool timeIsUp){
nextFlag = true;
RadioGroup grp=(RadioGroup)findViewById(R.id.radioGroup1);
RadioButton answer=(RadioButton)findViewById(grp.getCheckedRadioButtonId());
if(rda.isChecked()||rdb.isChecked()||rdc.isChecked()){
qid++;
Log.d("yourans", currentQ.getANSWER()+" "+answer.getText());
grp.clearCheck();
if(!timeIsUp && currentQ.getANSWER().equals(answer.getText())){
correct++;
}else{
lhm.put(currentQ.getQUESTION(),currentQ.getANSWER());
wrong++;
}
if(qid<5){
currentQ=quesList.get(qid);
setQuestionView();
}else{
score=correct;
Intent intent = new Intent(QuizActivity.this, ResultActivity.class);
Bundle b = new Bundle();
b.putInt("score", score);
intent.putExtras(b);
startActivity(intent);
return false;
}
}else{
Toast.makeText(getApplicationContext(),
"Please select atleast one Option",Toast.LENGTH_SHORT).show();
}
return true;
}
Hope this helps,
Fredrik