본문 바로가기

나의 플랫폼/안드로이드

꼭!!! 다이얼로그를 onDestroy에서 dismiss 시키는 버릇을 만들자~

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

제목 대로 안드로이드에서 다이얼로그를 만든 후, dismiss를 시키지 않고 Activity를 종료한 후,

WindowManager를 이용하여 addView를 추가 시키고자 할때 아래와 같은 에러 메세지를 보이게 된다.


참고:http://www.jjoe64.com/2011/06/how-to-fix-windowmanager.html


E/WindowManager( 1374): Activity com.jjoe64.example.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405446f8 that was originally added here
E/WindowManager( 1374): android.view.WindowLeaked: Activity com.jjoe64.example.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405446f8 that was originally added here
E/WindowManager( 1374):  at android.view.ViewRoot.<init>(ViewRoot.java:258)
E/WindowManager( 1374):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
E/WindowManager( 1374):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/WindowManager( 1374):  at android.view.Window$LocalWindowManager.addView(Window.java:424)
E/WindowManager( 1374):  at android.app.Dialog.show(Dialog.java:241)
E/WindowManager( 1374):  at com.jjoe64.example.MainActivity.showLoading(MainActivity.java:682)
E/WindowManager( 1374):  at com.jjoe64.example.view.HieraticalHostListView.loadData(HieraticalHostListView.java:84)
E/WindowManager( 1374):  at com.jjoe64.example.MainActivity.setupListViewStatus(MainActivity.java:479)
E/WindowManager( 1374):  at com.jjoe64.example.MainActivity.checkZabbixLogin(MainActivity.java:162)
E/WindowManager( 1374):  at com.jjoe64.example.MainActivity.onResume(MainActivity.java:279)
E/WindowManager( 1374):  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
E/WindowManager( 1374):  at android.app.Activity.performResume(Activity.java:3832)
E/WindowManager( 1374):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)
E/WindowManager( 1374):  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
E/WindowManager( 1374):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
E/WindowManager( 1374):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/WindowManager( 1374):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/WindowManager( 1374):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/WindowManager( 1374):  at android.os.Looper.loop(Looper.java:123)
E/WindowManager( 1374):  at android.app.ActivityThread.main(ActivityThread.java:3683)
E/WindowManager( 1374):  at java.lang.reflect.Method.invokeNative(Native Method)
E/WindowManager( 1374):  at java.lang.reflect.Method.invoke(Method.java:507)
E/WindowManager( 1374):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/WindowManager( 1374):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/WindowManager( 1374):  at dalvik.system.NativeStart.main(Native Method)
</init>


@Override
 protected void onStop() {
  super.onStop();
  if (loadingDlg != null) {
   loadingDlg.dismiss();
   loadingDlg = null;
  }
 }
위와 같이 onStop 부분에 다이얼로그를 dismiss 시키는 버릇을 들이자.