Configuration change : is either orientation change(phone rotation), or language settings change.
In case of configuration change, android will forcefully kill your activity and recreates it, unless you are not handling configuration changes on your own programmatically.
When android kills your activity due to configuration changes, it makes sure that it will definitely call onPause() and onSaveInstanceState. But there is no guarantee about call onStop and onDestroy. But android documentation doesn't say that it will not call onStop and onDestroy. it depends.
Life cycle in the case of configuration changes can be any of the below option 1, or 2, or 3, based on the situation. some times it might not kill activity at all if programmer is handling configuration changes programmatically, which is not a standard way to do.
1. onPause() -> onSaveInstanceState() -> onCreate() -> onStart() -> onRestoreInstanceState() -> onResume()
2. onPause() -> onSaveInstanceState() -> onStop() -> onCreate() -> onStart() -> onRestoreInstanceState() -> onResume()
3. onPause() -> onSaveInstanceState() -> onStop() -> onDestroy()->onCreate() -> onStart() -> onRestoreInstanceState() -> onResume()
In case of configuration change, android will forcefully kill your activity and recreates it, unless you are not handling configuration changes on your own programmatically.
When android kills your activity due to configuration changes, it makes sure that it will definitely call onPause() and onSaveInstanceState. But there is no guarantee about call onStop and onDestroy. But android documentation doesn't say that it will not call onStop and onDestroy. it depends.
Life cycle in the case of configuration changes can be any of the below option 1, or 2, or 3, based on the situation. some times it might not kill activity at all if programmer is handling configuration changes programmatically, which is not a standard way to do.
1. onPause() -> onSaveInstanceState() -> onCreate() -> onStart() -> onRestoreInstanceState() -> onResume()
2. onPause() -> onSaveInstanceState() -> onStop() -> onCreate() -> onStart() -> onRestoreInstanceState() -> onResume()
3. onPause() -> onSaveInstanceState() -> onStop() -> onDestroy()->onCreate() -> onStart() -> onRestoreInstanceState() -> onResume()
No comments:
Post a Comment