|Issue 39721:||4.2 Fragments: onResume() called before onCreateOptionsMenu()|
|46 people starred this issue and may be notified of changes.||Back to list|
On API <= 16 Fragment's onCreateOptionsMenu() is always called before onResume() which makes sense. On 4.2 the order has changed, which doesn't.
Nov 27, 2012
Agree. I had to modify my application to make it work because it depended on that call order.
Feb 15, 2013
It looks like this behavior was never guaranteed. It probably should have been, which would be a lot more convenient. However, ensuring that onResume() doesn't depend on onCreateOptionsMenu() will always be correct :/
Apr 7, 2013
What if activity sequence also changed in future version, causing tremendous crashes in app for people who upgraded their rom. Google shouldn't do this without proper documentation.
Jun 26, 2013
Its an issue for me, I want to update an item in my action bar, so I need to grab it from the Menu (in onCreateOptionsMenu()) and then update it in onResume(). With this new call order, I can't...
Dec 18, 2013
Sorry for coming late to this - and sorry if this is not the correct place to ask questions - but this does cause me some trouble at the moment... Is there some other life cycle method that's guaranteed to be called after onCreateOptionsMenu?
Dec 18, 2013
I believe you can call onPrepareOptionsMenu. The downside is that it gets called every time the options menu is displayed.
Apr 1, 2014
This seems crazy to me as well. I need to get a handle on one of the action bar buttons such that I can enable/disable it on events. However I run into the problem where my onResume sets up listeners (as it should), but callbacks get invoked before my options menu is set up. So now I have to register listeners in my onPrepareOptionsMenu which seems bad. IMHO onCreate should not finish until the menu is created or at the very least onResume should not be called until the menu is available.
|► Sign in to add a comment|