I was doing some tests for changing orientations. I use corwin42's AHQuickActions library for a menu which uses the PopupWindow class.
If I have a custom dialog open and change orientation, it works okay.
If I have a Popup menu open and change orientation, it works okay.
When I have launched a dialog from the popup menu, both of them are visible and then I get a crash here on orientation change:
I think due to the dialog the onClick handler for the popup has not finished yet. When it gets dismissed, the Activity is killed, and this code is run afterwards.
I think there are two solutions:
- Use CallSubDelayed to call the sub that shows the dialog. This lets the onClick handler to finish.
- Change the onClick handler to dismiss the popup before delegating the event. Not sure what other effects that will have
If I have a custom dialog open and change orientation, it works okay.
If I have a Popup menu open and change orientation, it works okay.
When I have launched a dialog from the popup menu, both of them are visible and then I get a crash here on orientation change:
B4X:
java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:653)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:362)
at android.view.WindowManagerImpl$CompatModeWrapper.removeViewImmediate(WindowManagerImpl.java:170)
at android.widget.PopupWindow.dismiss(PopupWindow.java:1256)
at de.amberhome.quickaction.PopupWindows.dismiss(PopupWindows.java:141)
at com.maximus.quickpopup.quickpopup$3.onClick(quickpopup.java:169)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4931)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
I think due to the dialog the onClick handler for the popup has not finished yet. When it gets dismissed, the Activity is killed, and this code is run afterwards.
I think there are two solutions:
- Use CallSubDelayed to call the sub that shows the dialog. This lets the onClick handler to finish.
- Change the onClick handler to dismiss the popup before delegating the event. Not sure what other effects that will have