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. Which device is best for testing development?

Hi everyone.
I am starting android development
which phone is good for testing? or is emulator good enough? I am
doing game devlopment, thanks

-- 

2. Hierarchy Viewer - Strange, buggy behavior

I've noticed some strange behavior with the hierarchy viewer.

I was just curious of anyone else had experienced the same and if
there were any resolutions out there.

Specifically the following two issues:

1. Wire-frame view: view is incomplete

* I use "Load View Hierarchy" to load the current view
* On the right hand side, there is a wire-frame view with a scrollbar
* The top and bottom of my view are cut-off, even with the scrollbar
* I cannot scroll to the bottom, hence I cannot investigate the
wireframe of the lowest layout elements.

Any ideas?

2. Pixel perfect view (missing Normal View)
http://developer.android.com/guide/developing/tools/hierarchy-viewer.html

* I open the pixel perfect view
* When it first loads normal view and loupe view are all black
* After a moment the active screen loads into loupe view and I can
scroll around
* Normal view disappears
* All that is left of normal view is are the controls (overlay,
refresh rate, zoom) and they are mangled
* To clarify the black screen of normal view disappears and the
controls move up until they are right below the title bar

???

Some details about my environment
SDK tools r5
java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)
Windows 7 Home Premium ver 6.1(build7600) 64bit

any help will be greatly appreciated - thank you,
Steve

-- 

3. Evaluate javascript from within a service

4. Finding dependencies of shared library

5. Telephony locator

6. Unable to resolve activity for: Intent

7. Code for sending SMS Alerts based on the Current System Time