Calling superclass implementations before logging messages


#1

I am a little confused as to why we have to call the superclass implementation of the lifecycle callback in the first place. I am hoping that this answer will help clarify why it is the first line of code in the lifecycle callback override definition.

Any insight would be great, thanks


#2

Some lifecycle methods are part of component creation, such as: onCreate, onStart, or onResume should typically call super first so that the app has had a chance to do any of the necessary setup that your code may rely on.

As a general rule with destruction methods such as onStop and onDestroy I usually call super as the last thing.

There are a handful of other methods where the order doesn’t really matter and you can call super anytime.