Android troubleshooting: Have leaked window com.android.internal.policy.impl.phonewindow$ that is originally added here

Source: Internet
Author: User

Original address: http://www.cnblogs.com/royenhome/archive/2011/05/20/2051879.html

Exception Scenario:

There are often time-consuming tasks that need to be handled in the application, such as reading large files, accessing network resources, and so on. In order to avoid the bad user experience due to the death of the program, usually we can solve the problem through thread +handler or Android-provided asynctask, and generally use the prompt control such as ProgressDialog to inform the user of the current program progress. The exceptions described in the title often appear in such scenarios and often obscure the real culprit that caused the exception.

Cause of the problem:

From the description of the exception, the general meaning is that there is a disclosure of the window handle, that is, failure to destroy a phonewindow in time. And that often misleads us by putting too much effort into finding so-called memory leaks. In fact, there is a situation where we have a serious exception due to some improper operation in the non-main thread, forcing the current activity to be closed. While shutting down, but failed to call dismiss in time to de-progressdialog, and so on, so that the system throws the error in the title, and masks the real cause of the error of the exception information.

One of the workarounds:

This solution does not really solve the problem, but to a certain extent, it can reveal the abnormal information that really leads to the error. That is, overriding the activity's OnDestroy method, calling dismiss in the method to dismiss the reference to ProgressDialog, and so on.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.