This projects demonstrates a strange behavior of the Android Activity lifecycle.
This example app is set up with ParentActivity
and ChildActivity
. ParentActivity
has one button that launches
ChildActivity
. ChildActivity
has a transparent background so that ParentActivity
isn't stopped when ChildActivity
starts. Both Activities are otherwise very vanilla.
When orientation change occurs after ChildActivity
has been launched, locking the device results in only ChildActivity.onStop()
being called, but not ParentActivity.onStop()
. If no orientation change has occured, then both ChildActivity.onStop()
and ParentActivity.onStop()
are called when the device is locked.
ParentActivity.onStart()
- Launch Child
ChildActivity.onStart()
- Lock the screen.
ChildActivity.onStop()
ParentActivity.onStop()
ParentActivity.onStart()
- Launch Child
ChildActivity.onStart()
- Rotate the screen
ChildActivity.onStop()
ChildActivity.onStart()
ParentActivity.onStop()
ParentActivity.onStart()
- Lock screen
ChildActivity.onStop()