1

In my activity I create an own dialog with spinner and edit box. The problem I got was orientation change - I got exception each time, so:

1) I added android:configChanges="orientation|keyboardHidden" in my activity's part in manifest.

2) Implemented onConfigurationChanged in my Activity, which more less look like this:

 @Override
    public void onConfigurationChange(Configuration newConfiguration) {
    super.onConfigurationChange(newConfiguration);
    if (mMyDialog != null && mMyDialog.isShowing() ) {
    mMyDialog.dismiss();
    }

Most times it works ok, but sometimes when I launch my dialog, activate Spinner (launch Spinners Pop-Up) and change orientation I got:

ERROR/AndroidRuntime(2928): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:385) ERROR/AndroidRuntime(2928): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:230) ERROR/AndroidRuntime(2928): at android.view.Window$LocalWindowManager.removeView(Window.java:432) ERROR/AndroidRuntime(2928): at android.app.Dialog.dismissDialog(Dialog.java:290) ERROR/AndroidRuntime(2928): at android.app.Dialog.access$000(Dialog.java:78) ERROR/AndroidRuntime(2928): at android.app.Dialog$1.run(Dialog.java:123) ERROR/AndroidRuntime(2928): at android.app.Dialog.dismiss(Dialog.java:280)

So it looks like the dialog is not dismissed on time ? Maybe I should override dismiss() method in MyDialog class and make sure all controls are 'closed' ? My dialog class is created as follows:

mMyDialog = new MyDialog(this);
mMyDialog.show();
Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103
andi
  • 11
  • 1

3 Answers3

0

May be you can try mMyDialog.hide(); function of dialog class

Yekmer Simsek
  • 4,102
  • 3
  • 21
  • 19
0

with mMyDialog.hide(), it beahaves the same.

I also add that this in MyDialog constructor is a Context object.

davidcesarino
  • 16,160
  • 16
  • 68
  • 109
olok
  • 1
0

I had an idea to prevent orientation changes when dialog with spinner is displayed, but found that there is no reliable way to do that. The best solution that I found is to replace spinner with a button. In my answer actually show how to restore spinner menu after orientation change, but you can easily choose not to do that.

Community
  • 1
  • 1
Juozas Kontvainis
  • 9,461
  • 6
  • 55
  • 66