"Android" common anomaly--android.view.windowleaked analysis and solutions

Source: Internet
Author: User

The problem is small, but I don't know if it's more troublesome. Exception information:

10-22 10:19:38.651 12723-12723/cn.com.zte.uc e/windowmanager:android.view.windowleaked:activity Cn.com.zte.uc.activites.shipTicket.OrderWrite1 has leaked window com.android.internal.policy.impl.phonewindow$ Decorview{423fee70 v.e ..... R......            D 0,0-455,230} That is originally added here at android.view.viewrootimpl.<init> (viewrootimpl.java:364) At Android.view.WindowManagerGlobal.addView (windowmanagerglobal.java:258) at Android.view.WindowMana Gerimpl.addview (windowmanagerimpl.java:69) at Android.app.Dialog.show (dialog.java:289) at Cn.com.zte . Uc.activites.BaseActivity.showInProgress (baseactivity.java:147) at Cn.com.zte.uc.activites.shipTicket.OrderWri Te1.onclick (orderwrite1.java:135) at Android.view.View.performClick (view.java:4446) at Android.view. View$performclick.run (view.java:18485) at Android.os.Handler.handleCallback (handler.java:733) at and Roid.os.Handler.dispatchMessage (handler.java:95) at Android.os.Looper.loop (looper.java:136) at android.app.ActivityThread.ma In (activitythread.java:5262) at java.lang.reflect.Method.invokeNative (Native Method) at Java.lang.re Flect. Method.invoke (method.java:515) at Com.android.internal.os.zygoteinit$methodandargscaller.run (ZygoteInit.java:85 1) at Com.android.internal.os.ZygoteInit.main (zygoteinit.java:667) at Dalvik.system.NativeStart.main (Native Method)

Copied directly from the project, the error code is show a progressdialog. Another case is that the finish activity also appears when the ProgressDialog is still displayed.


Cause Analysis:

Every activity in Android has a WindowManager form manager, as well as a dialog box built on top of an activity, and Popupwindow has a corresponding WindowManager form manager. Because dialogs and Popupwindown cannot be separated from activity , we go to finish () when a dialog or a Popupwindow is being displayed ( or Popupwindow), the window leaked exception is thrown, because this dialog (or Popupwindow) WindowManager has no one to associate with, So its form manager has leaked out.


Workaround:

Before closing (finish) an activity, make sure that the dialog or popupwindow attached to it is closed (dismiss).

"Android" common anomaly--android.view.windowleaked analysis and solutions

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.