Activity LifecycleOne more callback you might have not heard of.

Guneet Singh
1 min readMay 11, 2019

If you are developing android apps from a long time you must have encountered an activity restart on configuration changed like screen orientation, size, etc. There is a way, although not recommended, to avoid activity restarts by declaring in the manifest under activity tag’s configChange attribute, for example:-

<activity
android:name="MyActivity"
android:configChanges="orientation|screenSize"/
>

This way, your activity won’t restart and meaning no state changes in the lifecycle itself but an additional call will be received: -

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}

This call may be received anytime regardless of the state of the activity and hence must be handled inside the activity.

To give a better view of the Activity lifecycle this call must also be considered as a conditional callback under the activity lifecycle.

--

--

Guneet Singh
Guneet Singh

Written by Guneet Singh

Entrepreneur | Engineer | Creator | Contributor

No responses yet