Hide opened menu after orientation change android

In my application, there is requirement to show different menus on portrait and landscape mode.

This I have achieved using calling invalidateOptionsMenu() in onCreate(); and then I check orientation in onCreateOptionsMenu().

Problem

If I open options menu on portrait mode and change orientation, this menu item remains open in landscape mode.

Current Implementation:

Android handles this orientation change, so my activity recreates after change in orientation.

Options I have tried

  • Called closeOptionsMenu() in onDestroy().
  • Called closeOptionsMenu() in onSaveInstanceState().
  • Called Moved my code in onCreateOptionsMenu() to onPrepareOptionsMenu().
  • Please advise.

    Thanks,

    链接地址: http://www.djcxy.com/p/65364.html

    上一篇: 屏幕旋转后,AsyncTaskLoader未初始化

    下一篇: 方向更改android后隐藏打开的菜单