(QuizActivity.java)
mCheatButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Start Cheating
boolean answerIsTrue = mQuestionBank[mCurrentIndex].isAnswerTrue();
Intent i = new Intent(MainActivity.this, CheatActivity.class);
i.putExtra(EXTRA_ANSWER_IS_TRUE, answerIsTrue);
startActivityForResult(i, REQUEST_CODE_CHEAT);
//why are we using below code in book when above written code works fine
//just to save a line of code in GeoQuiz.Activity or there is something I didn’t understand
/*
boolean answerIsTrue = mQuestionBank[mCurrentIndex].isAnswerTrue();
Intent i = CheatActivity.newIntent(MainActivity.this, answerIsTrue);
startActivityForResult(i, REQUEST_CODE_CHEAT);
*/
}
});
(CheatActivity.java)
public static Intent newIntent(Context packageContext, boolean answerIsTrue){
Intent i = new Intent(packageContext, CheatActivity.class);
i.putExtra(EXTRA_ANSWER_IS_TRUE, answerIsTrue);
return i;