Is onCreateOptionsMenu()
of action bar called before or after the onStart()
of activity?
Asked
Active
Viewed 8,184 times
7

mthandr
- 3,062
- 2
- 23
- 33

Dhruva Bharadwaj
- 101
- 1
- 7
-
1Put a `Log.v(...)` message in each function to find out – Merlevede Mar 12 '14 at 02:12
-
A real easy way to tell would be to put a breakpoint or log in each and see which happens. – Gabe Sechan Mar 12 '14 at 02:12
-
Can you put some sample code illustrating where you feel the function isn't behaving appropriately? – dethtron5000 Mar 12 '14 at 02:31
-
`OnStart` `OnResume` `OnCreateOptionsMenu` – gkiko Aug 02 '14 at 12:57
3 Answers
8
onStart() is called first. (I tried putting log messages in the methods).

ElectronicGeek
- 3,312
- 2
- 23
- 35
4
I found this order to be the correct one
onCreate() - onStart() - onResume()- onCreateOptionsMenu()

CopsOnRoad
- 237,138
- 77
- 654
- 440
-
2I believe it's quite mind and app-breaking. I though in onStart I can access everything already. And looks like originally onCreateOptionsMenu was called somewhere during or after onCreate – norekhov May 24 '19 at 13:28
-2
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).
This is written in the Android documentation.

Aneesh Dangayach
- 202
- 1
- 4
-
onPrepareOptionsMenu is not called every time menu is to be displayed anymore. onInvalidateOptionsMenu() is required to call onCreateOptionsMenu() and onPrepareOptionsMenu() Jelly Bean onwards (except the first time ofcourse). This also makes me think onPrepareOptionsMenu() is pretty much useless, unless someone can give an example of a use-case to me. – Dhruva Bharadwaj Mar 13 '14 at 17:39