Android Activity had leaked window that was originally added

Source: Internet
Author: User

Today debug the program when the log suddenly print such errors, but the program is not crash, in order not to miss a mistake, I decided to investigate.

It was time to leave an activity and then prompt to exit the interface and then print the error:

Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): Activity com.linc.megatron.activity.ExamActivity has leaked window com.android.Internal[email protected] That's originally added hereGeneva- ,  -: Geneva:48.521: E/windowmanager (6340): android.view.WindowLeaked:Activity com.linc.megatron.activity.ExamActivity has leaked window com.android.Internal[email protected] That's originally added hereGeneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.view.viewroot.<init> (Viewroot.java: the)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.view.WindowManagerImpl.addView (Windowmanagerimpl.java:148)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.view.WindowManagerImpl.addView (Windowmanagerimpl.java: the)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.view.window$localwindowmanager.addview (Window.java:424)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.app.Dialog.show (Dialog.java:241)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): at Com.linc.megatron.Base. Backkeyactivity.showdialog (Backkeyactivity.java: the)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): at Com.linc.megatron.Base. Backkeyactivity.onkeydown (Backkeyactivity.java: +)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.view.KeyEvent.dispatch (Keyevent.java:1256)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.app.Activity.dispatchKeyEvent (Activity.java:2078)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): at Com.android.Internal. Policy.impl.phonewindow$decorview.dispatchkeyevent (Phonewindow.java:1709)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.view.ViewRoot.deliverKeyEventToViewHierarchy (Viewroot.java:2628)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.view.ViewRoot.handleFinishedEvent (Viewroot.java:2603)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.view.ViewRoot.handleMessage (Viewroot.java:1875)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.os.Handler.dispatchMessage (Handler.java: About)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.os.Looper.loop (Looper.java:123)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Android.app.ActivityThread.main (Activitythread.java:3687)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Java.lang.reflect.Method.invokeNative (Native Method)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Java.lang.reflect.Method.invoke (Method.java:507)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): at Com.android.Internal. os. Zygoteinit$methodandargscaller.run (Zygoteinit.java:867)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): at Com.android.Internal. os. Zygoteinit.main (Zygoteinit.java:625)Geneva- ,  -: Geneva:48.521: E/windowmanager (6340): At Dalvik.system.NativeStart.main (Native Method)

Obviously, I used dialog to confirm whether to exit, but the activity was destroyed and did not deal with dialog exit.

Workaround:

It's easy to solve the problem by knowing where the problem lies. Just close the dialog when the activity is destroyed.

    @Override    protectedvoid  OnDestroy () {        ifnull  ) {            Mdialog.dismiss ();        }        Super.ondestroy ();    }

Android Activity had leaked window that was originally added

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.