Error in newIntent (Context packageContext, boolean answerIsTrue)

here I get error

public static Intent newIntent (Context packageContext, boolean answerIsTrue){
    Intent intent = newIntent(packageContext, CheatActivity.class);
    intent.putExtra(EXTRA_ANSWER_IS_TRUE, answerIsTrue);
    return intent;

Wrong 2nd argument type. Found: ‘java.lang.Class<make.geoquiz.CheatActivity>’, required: 'boolean

But this code is taken from book and there is CheatActivity.class.

newIntent(packageContext, CheatActivity.class);


new Intent(packageContext, CheatActivity.class);

Great :slight_smile: such a silly mistake I made. Thank you.
Could you also tell me what comes after what in this code?

   public class CheatActivity extends AppCompatActivity {

private static final String EXTRA_ANSWER_IS_TRUE = "";
private boolean mAnswerIsTrue;

public static Intent newIntent (Context packageContext, boolean answerIsTrue){
    Intent intent = new Intent(packageContext, CheatActivity.class);
    intent.putExtra(EXTRA_ANSWER_IS_TRUE, answerIsTrue);
    return intent;

protected void onCreate(Bundle savedInstanceState) {

    mAnswerIsTrue = getIntent().getBooleanExtra(EXTRA_ANSWER_IS_TRUE, false);


    public class QuizActivity extends AppCompatActivity {

mCheatButton = findViewById(;
mCheatButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {

           boolean answerIsTrue = mQuestionBank[mCurrentIndex].isAnswerTrue();
           Intent intent = CheatActivity.newIntent(QuizActivity.this,answerIsTrue);

Im just totally lost and don’t know what executes first, what later and so on.

Could you please on this one also?
Many thanks i advance

The code you listed should execute in the following order.

  1. As part of the onCreate method in QuizActivity, an anonymous OnClickListener is attached to mCheatButton.
  2. The user clicks the cheat button, which calls the onClick method of the anonymous OnClickListener.
  3. The onClick method calls the newIntent static method to get an Intent suitable for starting CheatActivity.
  4. The onClick method calls startActivity, which tells the Android system to start an instance of the activity pointed to by the Intent.
  5. As part of the process of creating a CheatActivity instance, that activity’s onCreate method is called.

Great, thank you.
But if we were about to point which line starts after which this goes like this:

nr 1. boolean answerIsTrue = mQuestionBank[mCurrentIndex].isAnswerTrue();
nr 2. ?
nr 3. ?

Look at eachBetween activity and from when the operating system level, in the end what happened. First of all, when you click on the desktop GeoQuiz application launcher, the operating system does not start the application, but only a start activity applications. Rather, it starts the application launcher activity. In GeoQuiz applications, QuizActivity is its launcher activity.