Build & Publish - Activity lifecycle methods (onCreate, onStart, onResume, onPause, onStop, onDestroy)
Performance Impact of Activity Lifecycle Methods
Activity lifecycle methods control how your app behaves as users open, leave, or return to screens. Efficient use ensures smooth transitions and good battery life.
- onCreate: Called once when activity starts. Heavy work here can delay screen display, causing jank.
- onStart/onResume: Prepare UI and resources. Slow code here can reduce frame rate below 60fps, causing lag.
- onPause/onStop: Release resources to save memory and battery.
- onDestroy: Cleanup to avoid memory leaks.
Proper lifecycle management helps maintain 60fps frame rate and keeps memory use under device limits (~1.5GB on iOS, varies on Android).