Leaked window with dialog and wevView in Android -
i have bug in code when working multiple webviews java class receives reference of activity object.
this code:
try { mactivity.runonuithread(new runnable() { @suppresslint("newapi") public void run() { if (webview == null) return; if (visibility) { webview.setvisibility(view.visible); webview.requestfocus(); if (dialog != null && !dialog.isshowing()) { system.out.println("case1: " + dialog + " , activity: " + mactivity + ", mview " + webview); } else { dialog = webviewutils.showwebview(mactivity, webview); system.out.println("case2 " + dialog + " , activity: " + mactivity + ", mview " + webview); } if (!mactivity.isfinishing()) { dialog.show(); } } else { dialog.dismiss(); webview.setvisibility(view.gone); } } }); } catch (exception e) { system.out.println(system.out); log.d(constants.tag, e.getmessage()); }
this error stack:
09-22 14:12:21.682: e/windowmanager(1772): android.view.windowleaked: activity com.example.test.mainactivity has leaked window com.android.internal.policy.impl.phonewindow$decorview{41fc30e8 v.e..... r.....id 0,0-768,1184} added here 09-22 14:12:21.682: e/windowmanager(1772): @ android.view.viewrootimpl.<init>(viewrootimpl.java:346) 09-22 14:12:21.682: e/windowmanager(1772): @ android.view.windowmanagerglobal.addview(windowmanagerglobal.java:248) 09-22 14:12:21.682: e/windowmanager(1772): @ android.view.windowmanagerimpl.addview(windowmanagerimpl.java:69) 09-22 14:12:21.682: e/windowmanager(1772): @ android.app.dialog.show(dialog.java:286) 09-22 14:12:21.682: e/windowmanager(1772): @ com.itnt.javatest$3.run(javatest.java:199) 09-22 14:12:21.682: e/windowmanager(1772): @ android.app.activity.runonuithread(activity.java:4713) 09-22 14:12:21.682: e/windowmanager(1772): @ com.itnt.javatest.setvisibility(javatest.java:180) 09-22 14:12:21.682: e/windowmanager(1772): @ com.itnt.javatest.showad(javatest.java:122) 09-22 14:12:21.682: e/windowmanager(1772): @ com.itnt.javatest.showad(javatest.java:139) 09-22 14:12:21.682: e/windowmanager(1772): @ com.example.test.mainactivity.onclick(mainactivity.java:53) 09-22 14:12:21.682: e/windowmanager(1772): @ android.view.view.performclick(view.java:4438) 09-22 14:12:21.682: e/windowmanager(1772): @ android.view.view$performclick.run(view.java:18422) 09-22 14:12:21.682: e/windowmanager(1772): @ android.os.handler.handlecallback(handler.java:733) 09-22 14:12:21.682: e/windowmanager(1772): @ android.os.handler.dispatchmessage(handler.java:95) 09-22 14:12:21.682: e/windowmanager(1772): @ android.os.looper.loop(looper.java:136) 09-22 14:12:21.682: e/windowmanager(1772): @ android.app.activitythread.main(activitythread.java:5001) 09-22 14:12:21.682: e/windowmanager(1772): @ java.lang.reflect.method.invokenative(native method) 09-22 14:12:21.682: e/windowmanager(1772): @ java.lang.reflect.method.invoke(method.java:515) 09-22 14:12:21.682: e/windowmanager(1772): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) 09-22 14:12:21.682: e/windowmanager(1772): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:601) 09-22 14:12:21.682: e/windowmanager(1772): @ dalvik.system.nativestart.main(native method)
the lines stated there among block of code posted. if check if activity null or if dialog null, shouldn't ok code not break? lost. ideas welcomed. thank you.
just call dialog.dismiss()
, work fine .... :)
Comments
Post a Comment