Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

lifecycle - super class android life cycle

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...