Do I need to call "super.XXX" whenever I override a method?

Say, if I do not call the super.onPauseoverride from the superclass in the method Activity, I would get an error when called onPause(). But errors do not appear when I do not call super.XXXin the methods of ( onCreate, onStartCommand, ...) class derived from Service.

So, under what conditions should I call super.XXXin the override method?

+3
source share
4 answers

The documentation tells you what you need to call onPauseif you output the class Activity:

. , .

Service , onStartCommand .

( Android-), , , , . , , ( ) , .

+7

, super.XXX ?

. .

, :

  • javadocs ,
  • , , /
  • , .

javadoc .

0

, , @t-j-crowder .

. , .

, , , , "normal"?

, onKeyDown(), - (, "" ). :

  • , "" ,
  • , .
0

Only a subclass Activity(call it MyActivity) can know the client code, the client code cannot know Activity. However, it MyActivitycan know its base class Activity.

If an overridden method onPause()matches its base class, you do not need to explicitly override it.

0
source

Source: https://habr.com/ru/post/1793800/


All Articles