Although it is a small problem, it has also plagued me for a while. Now, let's write down and give myself a memo. You can also give others a reference.
Android. View. windowleaked literally understands that window leaked is probably a form leaked, that is, we often say Memory leakage. Why is the form leaked?
Cause:
We know that every activity in Android has a windowmanager form manager. Similarly, the dialog box and popupwindow built on an activity also have the corresponding windowmanager form manager. BecauseThe dialog box and popupdomainwn cannot be independent from the activity.So when a dialog or popupwindow is displayed, we finish () the activity that carries the dialog (or popupwindow), and the window leaked exception will be thrown, becauseNo one can attach the windowmanager of this dialog (or popupwindow )., So its form manager has been leaked.
Solution:
Before closing an activity, make sure that the attached dialog or popupwindow has been closed (dismiss.