In my app I have one fragment that I add by calling replace() on fragmentTransaction.
This fragment, let´s call it Fragment1, has some menu items that are added to action bar by calling onCreateOptionsMenu and setHasOptionsMenu(true) in onCreate(). From this fragment I then add another fragment that is added by calling add() on FragmentTransaction.
This fragment2 also has options menu but removes options for the first fragment. Then, on API 19 when I click on Back Button, it takes me back to Fragment1 and the options for this menu are added back, since the activity that hosts both of these fragments calls onCreateOptionsMenu and then onPrepare options menu. Also the same methods are called in Fragment1.
When I run my app on API 16, all the mentioned methods are called as well, but either the Menu Items for Fragment1 are not added back at all, or the three-dot-menu-group is added to a wrong place. I assume there is something different in the lower API, maybe even a bug. How should I fix this issue? Anyone with some experience?
This one is what it looks like when going back from the second fragment ot the first one and what it should look like on API 16:
This is how it is supposed to work and what it looks like on API 19 after going back from the second fragment to the first one:
I don´t attach any code because I think it is not relevant for this question. There is just some different behavior in different platforms and I just don´t see what I should do about it. Thanks for any help.