Android learns--activity Close and Dialog.dismiss conflict resolution (Activity has leaked window Com.android.internal.policy.impl.PhoneWindow )

Source: Internet
Author: User

This error occasionally occurs when we exit the entire program: Activity has leaked window Com.android.internal.policy.impl.PhoneWindow

The idea is that the form is closed, but dialog is still showing that activity has leaked window (activity infiltration form), which is probably the meaning.

Dialog dismiss () should be dropped before activity finish ().

My approach is to rewrite the OnDestroy () method of this activity, in which dialog is cleared:

/*** This method must be rewritten in order to refuse to exit the activity when the error dialog not dismiss*/@Overrideprotected voidOnDestroy () {//TODO auto-generated Method Stub        Try{Mydialog.dismiss (); }Catch(Exception e) {System.out.println ("Mydialog canceled, failed!" "); //Todo:handle Exception        }        Super. OnDestroy (); }

Android learns--activity Close and Dialog.dismiss conflict resolution (Activity has leaked window Com.android.internal.policy.impl.PhoneWindow )

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.