onCreate, onCreateOptionsMenu, onResume, what is the order of execution?

CodingBird picture CodingBird · Sep 23, 2013 · Viewed 9.1k times · Source

I'm sorry if this question was asked before... Well anyway as what the title asked, when does onCreateOptionsMenu executed? before or after onResume?

In my app, when the activity first run/opened the order will be onCreate --> onResume --> onCreateOptionsMenu

But if I change the orientation of the device, it'll automatically called onDestroy and thus the activity will be re-created, in this case the order will be onCreate --> onCreateOptionsMenu --> onResume

I'm so confused now... anybody can give an explanation on this?

Answer

Peregreen picture Peregreen · Sep 23, 2013

You can read about onCreateOptionsMenu this :

This is only called once, the first time the options menu is displayed. To update the menu every time it is displayed, see onPrepareOptionsMenu(Menu).