Difference between code before and after super()

后端 未结 3 1576
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-04 16:37

Look at the sample codes below

@Override
protected void onPause() {
    ...some code here...
    super.onPause();
}

and

@O         


        
3条回答
  •  清歌不尽
    2020-12-04 17:12

    You should not place any of your code before super.onPause(), cause this method lets the system do what it needs to do to properly pause your application. Any code you want to execute in the onPause() callback should be placed after the call to super.onPause(). Hope this helps.

    Quote from Activities:

    Note: Your implementation of these lifecycle methods must always call the superclass implementation before doing any work, as shown in the examples above.

提交回复
热议问题