xxv / android-lifecycle

A diagram of the Android Activity / Fragment lifecycle
5.26k stars 681 forks source link

onCreateOptionsMenu is called before onResume #20

Closed gregd closed 4 years ago

gregd commented 8 years ago

When device is rotated, onCreateOptionsMenu and onPrepareOptionsMenu methods are called before onResume.

xxv commented 8 years ago

What device/OS/version are you using?

gregd commented 8 years ago

Last year I was testing my app on Samsung P5100, Android 4.1. That strange sequence of events occurred on that device.

Today I have a new Samsung SM-T815, Android 5.0.2. I also use support libs in my app. And surprisingly the events sequence is correct now.

I guess that the problem I faced was caused by a bug in Android 4.1. Unfortunately, I have no P5100 device to repeat the test. So probably my issue should be closed.

israNascimento commented 5 years ago

I'd the same issue with Nexus Emulator API 25. If anyone is searching here for a workaround to this issue, just call invalidateOptionsMenu() on your onResume method.