i suggest to create a callback-function in your fragment to avoid timing issues with onResume() and onCreateOptionsMenu().
doing the following works flawless for me:
- create and add your fragment to your activity
- leave a reference of this fragment in your activity
- create a public method doSomethingWithTheMenu() in your fragment
- call this method from within your activity when onCreateOptionsMenu(Menu menu) is called.
example:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (this.myFragment != null) {
this.myFragment.doSomethingWithTheMenu(menu);
}
return true;
}