methods – Android: Call super() at the beginning or end of onStart(), onStop(), onDestroy() in activity?-ThrowExceptions

Exception or error:

Where in onStart(), onStop(), onDestroy() of an activity do I call super.onStart(), super.onStop(), super.onDestroy() ?

How to solve:

That’s my way of calling these super methods:

  • OnCreate(): Definitely the first thing.
  • OnDestroy(): The last thing.
  • OnStop(): The last thing.

However, for the last two, no matter where you call them (in most most cases). So some people prefer to put them at the first to be consistent.

###

I would call super in the begining, I would probably have the base class
complete its work before I do the work of the derived, like the rule in Java

Leave a Reply

Your email address will not be published. Required fields are marked *