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