Activity has leaked window com. Android. Internal. Policy. impl. phonewindow $ decorview

Source: Internet
Author: User

Exception scenarios:

It is often necessary to process time-consuming work in applications, such as reading large files and accessing network resources. In order to avoid poor user experience caused by program death, we can solve this problem through thread + handler or asynctask provided by Android, the current program progress is usually notified using a prompt control such as progressdialog. The exceptions described in the title often appear in such scenarios, and often conceal the real culprit of exceptions.

 

Cause:

In the exception description, it means that a phonewindow cannot be destroyed in time due to window handle leakage. This tends to mislead us and focus too much on finding the so-called memory leakage. In fact, there is a serious exception caused by improper operations in some of our non-main threads, which forces the current activity to be closed. At the same time, dismiss was not promptly called to release progressdialog and so on, thus the system throws an error in the title, and masks the exception information that actually leads to this error.

 

One solution:

This solution does not actually solve the problem, but can reveal the exception information that actually leads to errors to a certain extent. That is, override the ondestroy method of the activity, and call dismiss in the method to release references to progressdialog and so on.

Solution 2:

The solution is to add Android. Permission. reorder_tasks

Related Article

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.