Activity leaked into the orientation change window when opening SubMenu

I have a problem with my Android app. In this mode there is an options menu.

The menu is as follows:

<menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:title="@string/tx_1" android:id="@+id/menu_1" > <menu> <group android:checkableBehavior="single"> <item android:title="@string/tx_2" android:id="@+id/menu_2" /> <item android:title="@string/tx_3" android:id="@+id/menu_3" /> </group> <item android:title="@string/tx_4" android:id="@+id/menu_4" android:checkable="true" /> </menu> </item> <item android:title="@string/tx_5" android:id="@+id/menu_5" /> </menu> 

So, when you click on the first element there is SubMenu. It looks like a dialog, but I cannot find a way to get a link to this dialog. When I rotate the device, a window error leaks. So, it looks like Android is not closing SubMenu. Is there any way to prevent this error? SubMenu disappears, of course, after a recreation caused by a change in orientation. I can open the options menu again, but not SubMenu. Is it possible to simulate a click on the first menu item?

Thanks in advance!

And by the way, I don’t want to get around the rotation by changing the manifest.

+4
source share
1 answer

A simple solution would be to prevent the destruction of the Activity instance when the orientation of the application changes. You can do this by declaring the following in your manifest:

 <activity android:configChanges="orientation" ... /> 
0
source

All Articles