super class android life cycle

房东的猫 提交于 2019-11-28 05:37:10

问题


Why is it that you need to call the super class in the android lifecycle? For example, in onCreate you need to call super.onCreate, or onDestroy super.onDestroy.


回答1:


It makes sure that any relevant lifecycle management code across the full class hierarchy gets invoked.

If you have MyBaseActivity that extends Activity, and MySpecificActivity that extends MyBaseActivity, calling through to the lifecycle methods in the superclass at each level means MyBaseActivity will still be able to respond to lifecycle events.



来源:https://stackoverflow.com/questions/5395672/super-class-android-life-cycle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!