android-lifecycle
android-lifecycle copied to clipboard
Clarification: onCreateOptionMenu() called ones but onPrepareOptionMenu() every time
Fact:
onCreateOptionMenu() called ones but onPrepareOptionMenu() every time.
Problem:
Block diagram shows that every time onResume() called both onCreateOptionMenu() and onPrepareOptionMenu() are called. Which is not true.
Solutions: "Called once, the first time the options menu is displayed or if menu invalidated" comment need to be added there or condition (diamond-like) block with text "first menu display or invalidated" and "yes" and "no" branches
"called once" - under which conditions? The above is true for activity but not for fragments. If you have backstack, every backing (assuming backstack is single container based) will trigger creation of view and the menu (that is, among others onCreateOptionsMenu, onPrepareOptionsMenu will be called). If backstack is multi container based (I don't even know if it's officially supported by google), I think onCreateOptionsMenu/onPrepareOptionsMenu will even be called for fragment that's in backstack but in different container then the upper fragment.
The above is true for activity but not for fragments
If the above is true only for activity, then changes should be made only for activity diagram.
@xxv any comment?