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. Android/Java Developers Wanted - Portland, OR

Android Developers,

I didn't see any rule against circulating job opportunities, so hope that I am 
OK doing this. I am a recruiter (been doing this for 30 years) and this is 
initially a  contract position. It could possibly convert to direct employment. 
Please contact me (contact info below) if you've any questions or would like to 
apply. Thank you.

ANDROID Application Developers/Architects
Multiple Openings
WORK LOCATION: Portland, OR
TYPE OF WORK/DURATION:Contract4-6 months (possible extension)

Description
Join a creative group of engineers and developers in Portland, Oregon that are 
leading the way in the development of mobile device applications. Experience 
developing complex Android apps that access remote web services and access 
large amounts of data is desired. For this position we are looking for an 
Android Mobile Application Architect (Java).

Skills/Experience:
* Java skills
* Experience building complex Android standalone client applications and user 
interfaces
* Web service technology and services expertise
* Expert knowledge of the Android SDK
* BS in Computing Science or related field preferred

Desired:
* Additional mobile application development experience (iPhone, Blackberry, 
Windows Mobile, Symbian, etc)
* One or more published Android application


Thank you,
Brian

Brian Hochhalter
Pacific NW Area Manager
Direct:     (714) 986-5575
Mobile:    (503)-349-4159
www.AmtecHC.com<http://www.AmtecHC.com>
Amtec Resource 
Center<http://blog.amtec-resources.com/2006/02/01/welcome-amtec-resource-center/>
[cid:image005.jpg@01CB07AF.049ADBC0][cid:image006....@01cb07af.049adbc0]

-- 

2. how to debug the sync contact in the emulator

In the 2.1 source code, I want to know the sync working step, so i set
the break point in the  requestSync()(ContentResolver.java) , then I
choose the gmail account to sync  now,  the break point didn't work.

so i want to know how to debug it?

-- 

3. How to select multi phone number from phone book?

4. Moving to the next ImageView in HorizontalScrollview?

5. Force Close when running AccountManager.get(this).getAccounts()

6. Retrieving Contact Information (Name, Number, and Email) from the Phone book

7. Creating an Android VN