I found the problem... and a solution
In my activity, i show the dialog using:
this.showDialog(R.layout.waiting_dialog);
(where 'this' is the current activity).
Then this code, part of my activity, dismisses it:
// Do something with bmToSave and insert it into the MediaStore.
final PictureInserter ph = new PictureInserter(getApplicationContext
(), bmToSave) {
@Override
public void ready(String path, Uri uri) {
this.dismissDialog(R.layout.alert_dialog_waiting);
}
After an orientation change, the problem is that 'this' is still the
old destroyed acivity, when the 'ready' is called back when the
picture is properly inserted into the MediaStore.
I changed the code as follows:
// Do something with bmToSave and insert it into the MediaStore.
final PictureInserter ph = new PictureInserter(getApplicationContext
(), bmToSave) {
@Override
public void ready(String path, Uri uri) {
ACTIVE_INSTANCE.dismissDialog(R.layout.alert_dialog_waiting);
}
where 'ACTIVE_INSTANCE' is set to 'this' in the onCreate (and set to
'null' in the onDestroy).
This works fine.
On Jul 12, 11:13 pm, Streets Of Boston <[email protected]>
wrote:
> I'm seeing this behavior now too (Cupcake release).
>
> showDialog(id) --> config change --> dismissDialog(id) won't work more
>
> When calling dismissDialog(id) after a config change doesn't do
> anything (not dismissing the dialog, but no error-message either).
>
> Something is wrong here...
>
> On May 21, 4:53 am, idev <[email protected]> wrote:
>
>
>
> > Hi
> > I am using the showDialog anddismissDialogmethods to show progress
> > dialogs in my app. Moved from creating the dialog and calling show()
> > on it to using this in order to save state when changing orientation.
> > But when I change the orientation from portrait->landscape->portrait,
> > thedismissDialogmethod call no longer dismisses the dialog. The
> > dialog stay there all the time and I need to press the back button for
> > it to disappear.
> > To overcome this issue, I tried adding a removeDialog in onDestroy so
> > that the dialog is not created/displayed twice and before orientation
> > change, the dialog is removed. Tried adding log statements and this is
> > what happens
> > 05-21 12:35:14.064: DEBUG/MyClass(193): *************callingShowDialog
> > 05-21 12:35:14.064: DEBUG/MyClass(193): *************onCreareDialog
>
> > 05-21 12:35:15.385: DEBUG/MyClass(193):
> > *************onSaveInstanceState
> > 05-21 12:35:15.415: DEBUG/MyClass(193): *************onDestroy
>
> > 05-21 12:35:15.585: DEBUG/MyClass(193): *************callingShowDialog
> > 05-21 12:35:15.585: DEBUG/MyClass(193): *************onCreareDialog
> > 05-21 12:35:15.715: DEBUG/MyClass(193): *************onCreareDialog
> > 05-21 12:35:17.214: DEBUG/MyClass(193):
> > *************onSaveInstanceState
> > 05-21 12:35:17.214: DEBUG/MyClass(193): *************onDestroy
>
> > 05-21 12:35:17.275: ERROR/WindowManager(193):
> > android.view.WindowLeaked: Activity com.android.MyClass has leaked
> > window com.android.internal.policy.impl.phonewindow$decorv...@43362088
> > that was originally added here
> > Some error statements....
> > 05-21 12:35:17.395: DEBUG/MyClass(193): *************callingShowDialog
> > 05-21 12:35:17.395: DEBUG/MyClass(193): *************onCreareDialog
> > 05-21 12:35:17.475: DEBUG/MyClass(193): *************onCreareDialog
>
> > Initially when the activity is displayed, the onCreateDialog is called
> > once and on changing the orientation, onSaveInstanceState and
> > onDestroy are called.
> > But after that, onCreateDialog is called twice (once by a call to
> > showDialog which I make, but why the 2nd time?) and this happens every
> > time I change the orientation hence forth.
> > Any idea why that happens?
> > Thanks- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---