android.view.WindowLeaked in onClick code -


i think error occurs @ code:

godirect.setonclicklistener(                 new view.onclicklistener(){                     @override                     public void onclick(view view) {                          alertdialog.builder mbuilder = new alertdialog.builder(scanactivity.this);                         view mview = getlayoutinflater().inflate(r.layout.serial_popup, null);                          mbuilder.setview(mview);                         final alertdialog dialog = mbuilder.create();                          dialog.show();                          button authbutton = (button)mview.findviewbyid(r.id.authbutton);                           authbutton.setonclicklistener(                                 new view.onclicklistener(){                                     @override                                     public void onclick(view view) {                                         intent myintent = new intent(scanactivity.this, itemsetactivity.class);                                         startactivity(myintent);                                         finish();                                          overridependingtransition(r.xml.madefadein, r.xml.splashfadeout);                                     }                                 }                         );                     }                 }         ); 

this code return windowleaked exception. can't solve it.

to solve windowleaked exception, have use dialog.dismiss , change dialog's value null. use dismiss() in inner class, declared dialog final. declare final, can't change dialog's value null. how solve error? or there solution don't declare dialog final?

i'm sorry i'm not fluent in english.

e/windowmanager: android.view.windowleaked: activity com.example.dh.qrock.scanactivity has leaked window com.android.internal.policy.impl.phonewindow$decorview{21f703da v.e..... r....... 0,0-1025,904} added here                      @ android.view.viewrootimpl.<init>(viewrootimpl.java:363)                      @ android.view.windowmanagerglobal.addview(windowmanagerglobal.java:261)                      @ android.view.windowmanagerimpl.addview(windowmanagerimpl.java:69)                      @ android.app.dialog.show(dialog.java:298)                      @ com.example.dh.qrock.scanactivity$4.onclick(scanactivity.java:217)                      @ android.view.view.performclick(view.java:4757)                      @ android.view.view$performclick.run(view.java:19772)                      @ android.os.handler.handlecallback(handler.java:739)                      @ android.os.handler.dispatchmessage(handler.java:95)                      @ android.os.looper.loop(looper.java:135)                      @ android.app.activitythread.main(activitythread.java:5228)                      @ java.lang.reflect.method.invoke(native method)                      @ java.lang.reflect.method.invoke(method.java:372)                      @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:959)                      @ com.android.internal.os.zygoteinit.main(zygoteinit.java:754) application terminated. 

this log. scanactivity:217 showdialog() code.

use dismiss log.

09/11 19:15:37: launching app cold swapped changes. $ adb shell start -n "com.example.dh.qrock/com.example.dh.qrock.introactivity" -a android.intent.action.main -c android.intent.category.launcher connected process 26200 on device foxconn-tg_l800s-phxglmd5a1102221 i/art: late-enabling -xcheck:jni i/instantrun: instant run runtime started. android package com.example.dh.qrock, real application class null. w/art: failed find oatdexfile dexfile /data/data/com.example.dh.qrock/files/instant-run/dex/slice-slice_5-classes.dex ( canonical path /data/data/com.example.dh.qrock/files/instant-run/dex/slice-slice_5-classes.dex) checksum 0x0b3e0e9d in oatfile /data/data/com.example.dh.qrock/cache/slice-slice_5-classes.dex i/firebaseinitprovider: firebaseapp initialization unsuccessful w/art: before android 4.1, method android.graphics.porterduffcolorfilter android.support.graphics.drawable.vectordrawablecompat.updatetintfilter(android.graphics.porterduffcolorfilter, android.content.res.colorstatelist, android.graphics.porterduff$mode) have incorrectly overridden package-private method in android.graphics.drawable.drawable d/openglrenderer: render dirty regions requested: true d/atlas: validating map... i/adreno-egl: <qegldrvapi_eglinitialize:410>: egl 1.4 qualcomm build: au_linux_android_la.bf.1.1.1_rb1.05.00.02.042.020_msm8974_la.bf.1.1.1_rb1__release_au ()               opengl es shader compiler version: e031.25.03.06               build date: 03/04/15 wed               local branch: mybranch8102437               remote branch: quic/la.bf.1.1.1_rb1.14               local patches: none               reconstruct branch: au_linux_android_la.bf.1.1.1_rb1.05.00.02.042.020 + 68ecddf + 5d22558 + bf8c1a3 + 746ac28 +  nothing i/openglrenderer: initialized egl, version 1.4 d/openglrenderer: enabling debug mode 0 i/timeline: timeline: activity_idle id: android.os.binderproxy@208829d2 time:119368343 d/audiomanager: playsoundeffect effecttype:0 i/timeline: timeline: activity_launch_request id:com.example.dh.qrock time:119368871 i/timeline: timeline: activity_idle id: android.os.binderproxy@35a99f90 time:119369044 d/audiomanager: playsoundeffect effecttype:0 i/timeline: timeline: activity_launch_request id:com.example.dh.qrock time:119377512 i/system.out: eyjhbgcioijiuzi1niisinr5cci6ikpxvcj9.eyj1c2vyx2vtywlsijoidgvzdebnbwfpbc5jb20ilcjpyxqioje1mduxmjq5ndcsimv4cci6mtuwntcyotc0nywiaxnzijoiew91bmdolmnvbsisinn1yii6invzzxjjbmzvin0.gtxyxypnpucjpcxqdt1yov-2y-8garv0eiafnpttmhi i/timeline: timeline: activity_idle id: android.os.binderproxy@28652c6f time:119377852 d/audiomanager: playsoundeffect effecttype:0 i/timeline: timeline: activity_launch_request id:com.example.dh.qrock time:119378320 w/dynamitemodule: local module descriptor class com.google.android.gms.vision.dynamite not found. w/resourcesmanager: asset path '/system/framework/com.android.media.remotedisplay.jar' not exist or contains no resources. w/resourcesmanager: asset path '/system/framework/com.android.location.provider.jar' not exist or contains no resources. i/dynamitemodule: considering local module com.google.android.gms.vision.dynamite:0 , remote module com.google.android.gms.vision.dynamite:801 i/dynamitemodule: selected remote version of com.google.android.gms.vision.dynamite, version >= 801 i/art: dexfile_isdexoptneeded failed open oat file '/data/dalvik-cache/arm/data@data@com.google.android.gms@app_chimera@m@00000015@dynamitemodulesb_gmscore_prodlmp_xxhdpi_release.apk@classes.dex' file location '/data/data/com.google.android.gms/app_chimera/m/00000015/dynamitemodulesb_gmscore_prodlmp_xxhdpi_release.apk': failed open oat filename reading: no such file or directory e/camera: jk: version=v00.13.01.00           ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ e/camera: jk: state=ready           �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� i/choreographer: skipped 39 frames!  application may doing work on main thread. i/timeline: timeline: activity_idle id: android.os.binderproxy@515763c time:119379342 d/audiomanager: playsoundeffect effecttype:0 d/audiomanager: playsoundeffect effecttype:0 i/timeline: timeline: activity_launch_request id:com.example.dh.qrock time:119381058 i/timeline: timeline: activity_idle id: android.os.binderproxy@23e82471 time:119381154 d/camera: app passed null surface 

it okay declare dialog final , use them show or dismiss. should enclose dialog show or dismiss in try catch because parent of dialog show may vanish , still not close it. below.

 try{      showdialog();  }catch(exception e){   } 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -