마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

WebView 종료시 처리에 대해서

0 추천
Activity에 WebView를 추가하고 나서.. onPagedStarted에서 progressDialog 처리를 하고 있습니다.

그런데, back key를 통해서 Activity가 닫힐 때, onPagedStarted가 호출 되면서... 아래와 같은 오류가 발생합니다.

12-22 17:13:20.787: E/WindowManager(7547): android.view.WindowLeaked: Activity com.xxx.xxx.xxx.MyActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{3f5b8ec4 G.E..... R.....ID 0,0-96,96} that was originally added here
12-22 17:13:20.787: E/WindowManager(7547):     at android.view.ViewRootImpl.<init>(ViewRootImpl.java:363)
12-22 17:13:20.787: E/WindowManager(7547):     at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:271)
12-22 17:13:20.787: E/WindowManager(7547):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
12-22 17:13:20.787: E/WindowManager(7547):     at android.app.Dialog.show(Dialog.java:298)
12-22 17:13:20.787: E/WindowManager(7547):     at com.xxx.xxx.xxx.MyActivity.showProgress(MyActivity.java:118)
12-22 17:13:20.787: E/WindowManager(7547):     at com.xxx.xxxx.MyActivity.access$200(MyActivity.java:23)
12-22 17:13:20.787: E/WindowManager(7547):     at com.xxx.xxx.xxx.MyActivity$MyWebClient.onPageStarted(MyActivity.java:195)
12-22 17:13:20.787: E/WindowManager(7547):     at com.android.webview.chromium.WebViewContentsClientAdapter.onPageStarted(WebViewContentsClientAdapter.java:501)
12-22 17:13:20.787: E/WindowManager(7547):     at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:144)
12-22 17:13:20.787: E/WindowManager(7547):     at android.os.Handler.dispatchMessage(Handler.java:102)
12-22 17:13:20.787: E/WindowManager(7547):     at android.os.Looper.loop(Looper.java:135)
12-22 17:13:20.787: E/WindowManager(7547):     at android.app.ActivityThread.main(ActivityThread.java:5254)
12-22 17:13:20.787: E/WindowManager(7547):     at java.lang.reflect.Method.invoke(Native Method)
12-22 17:13:20.787: E/WindowManager(7547):     at java.lang.reflect.Method.invoke(Method.java:372)
12-22 17:13:20.787: E/WindowManager(7547):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
12-22 17:13:20.787: E/WindowManager(7547):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

물론, 오류가 발생하는 원인은 알 수 있으나 왜 Activity가 닫힐 때, onPagedStarted가 다시 호출되는지 여부를 알 수 없네요.

고수님들의... 가르침 부탁 드립니다.
단순무식 (140 포인트) 님이 2015년 12월 22일 질문

1개의 답변

0 추천
onDestroy 에서 webView 에 해당하는 progress dialog 를 닫도록 설정하세요
aucd29 (218,390 포인트) 님이 2015년 12월 22일 답변
Progress를 닫는 동작이 문제가 아니라... 닫고.. Activity가 onDestroy가 되었지만... 다시 onPageStarted가 호출되면서 Progress 처리가 되기 때문에 오류가 납니다. (원인은 알고 있습니다만...)왜 Activity가 닫혔지만... onPageStarted가 호출되는가가 궁금한 사항이었습니다.
...