开发者

super class android life cycle

开发者 https://www.devze.com 2023-02-18 06:14 出处:网络
Why is it that you need to call the super class in the a开发者_开发技巧ndroid lifecycle? For example, in onCreate you need to call super.onCreate, or onDestroy super.onDestroy.It makes sure that any r

Why is it that you need to call the super class in the a开发者_开发技巧ndroid lifecycle? For example, in onCreate you need to call super.onCreate, or onDestroy super.onDestroy.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号