Overriding lifecycle callbacks as public


#1

Listing 3.3 Overriding more lifecycle methods (QuizActivity.java)

@Override
public void onStart() {
    super.onStart();
    Log.d(TAG, "onStart() called");
}

@Override
public void onResume() {
    super.onResume();
    Log.d(TAG, "onResume() called");
}

@Override
public void onPause() {
    super.onPause();
    Log.d(TAG, "onPause() called");
}

@Override
public void onStop() {
    super.onStop();
    Log.d(TAG, "onStop() called");
}

@Override
public void onDestroy() {
    super.onDestroy();
    Log.d(TAG, "onDestroy() called");
}

The lifecycle callbacks are declared as protected in the superclass, but when we override them we make them public. Is there a rationale for doing this or is this simply a typo?


#2

We just want to override the method of superclass, so what would we need is make a same signature of the method. Please to turn Alt+O to choose method of superclass which is we want to override them (only method has been mentioned in the book). Good luck!