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