Do activity lifecycle callbacks have to be implemented in pairs?
e.g.
- if you override
onCreateyou must also overrideonDestroy? - if you override
onStartyou must also overrideonStop? - if you override
onResumeyou must also overrideonPause?
i.e. would your app crash if you implement onCreate but omit to implement onDestroy say?
Is it just good practice to implement in pairs, or does it not matter at all (just implement what you need)?
Only implement what you need. The others will automatically be called from the superclass (
Activity). You should only override them if you need to add functionality at that point of the lifecycle. Typically, if you’re handling something inonPause(), you’re probably also going to handle the inverse operation inonResume(). That’s definitely not always the case though.EDIT: Going by your edit, without seeing the code, I’m going to guess you forgot the call to
super.onStart()andsuper.onResume(). If not, post your implementations and stack trace for the crash.