AlertDialog.show() leaks when phone rotates

by Mark Wyszomierski » Fri, 18 Dec 2009 07:27:25 GMT


Sponsored Links
 Hi,

There are lots of code samples on third party sites where an alert
dialog is built and shown like this:

    new AlertDialog.Builder(context).setMessage("Test.").show();

If the dialog is left open when the phone rotates, it seems to leak:

12-17 18:23:47.543: ERROR/WindowManager(2440): Activity
com.test.ActivityMain has leaked window
com.android.internal.policy.impl.phonewindow$decorv...@43775a28 that
was originally added here
12-17 18:23:47.543: ERROR/WindowManager(2440):
android.view.WindowLeaked: Activity com.test.ActivityMain has leaked
window com.android.internal.policy.impl.phonewindow$decorv...@43775a28
that was originally added here
12-17 18:23:47.543: ERROR/WindowManager(2440):     at
android.view.ViewRoot.<init>(ViewRoot.java:214)
.... etc ...

We can use the showDialog() methods, but the above does come in handy
sometimes. Is there a proper way to clean up dialogs created in this
manner?

Thanks

--



AlertDialog.show() leaks when phone rotates

by Romain Guy » Fri, 18 Dec 2009 08:04:40 GMT


 Just call theDialog.dismiss() from onDestroy().



>


Sponsored Links


Other Threads

1. File upload or synching with Android

I'm looking for sample code or hints for connecting to pc/mac/linux
via usb or bluetooth to read/write a file or a stream of text.

TIA,

Fred

--~--~---------~--~----~------------~-------~--~----~

2. Open source software license

About the Android Software Development Kit License Agreement on
http://code.google.com/android/download.html,  I note that "use,
reproduction and distribution of components of the SDK licensed under
an open source software license are governed solely by the terms of
that open source software license and not this License Agreement.".

If we wish to develop and sell mobile devices using the Android
platform, do we need to sign the "Open Source Software License" now ?

Thanks, I look forward to hearing from you.

--~--~---------~--~----~------------~-------~--~----~

3. Return result from a service

4. Help on porting

5. Should we be putting all potentially blocking operations like http requests) in Threads?

6. Should we be putting all potentially blocking operations like http requests) in Threads?

7. Should we be putting all potentially blocking operations like http requests) in Threads?