Android

Unable to add window … is your activity running?

Fatal Exception: android.view.WindowManager$BadTokenException
Unable to add window — token android.os.BinderProxy@795db42 is not valid; is your activity running?
android.view.ViewRootImpl.setView (ViewRootImpl.java:581)
android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:272)
android.view.WindowManagerImpl.addView (WindowManagerImpl.java:69)
android.app.ActivityThread.handleResumeActivity (ActivityThread.java:3292)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2479)
android.app.ActivityThread.access$800 (ActivityThread.java:144)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1359)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:155)
android.app.ActivityThread.main (ActivityThread.java:5696)
java.lang.reflect.Method.invoke (Method.java)
java.lang.reflect.Method.invoke (Method.java:372)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1028)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:823)

 

Fabric 사이트의 Crashlytics에 올라오는 지긋지긋한 오류 보고이다.
대처를 해도 계속 나온다.
뭔가 구멍이 있다.
찾아야한다.

 

가이드라인까지 알려줘서 처리했으나 계속 발생 중이다.

Crash Insights

Heads Up!
Unable to add window — token is not valid; is your activity running?

Details:
This crash is usually caused by your app trying to display a dialog using a previously-finished Activity as a contextFor example, this can happen if an Activity triggers an AsyncTask that tries to display a dialog when it is finished, but the user navigates back from the Activity before the task is completed.
External resources:

  1. Android – Displaying Dialogs From Background Threads
  2. Error : BinderProxy@45d459c0 is not valid; is your activity running?

액티비티가 종료중인지 여부를 체크하는 로직을 구현하였으나 효과는 없다.

if (! MainActivity.this.isFinishing()) {
}

마지막으로 Handler 메소드를 사용해보아야겠다.

 

Leave a Reply

error: Content is protected !!