Android/Technic

Dialog를 띄울 때 is your activity running이 뜰 때

등촌동 꼬북이 2021. 5. 4. 14:58

개발하다보면 Dialog를 띄울때가 있다.

 

근데 is your activity running? 이러면서 안될때가 있는데

 

이때 문제는 getApplicationContext() 나 this를 써서 그렇다.

 

이걸 MainActivity.this를 쓰면 Dialog가 잘 뜬다.

 

XXDialog dialog = new XXDialog(MainActivity.this);
dialog.show();

 

[ Android / Kotlin ] AlertDialog 오류 : Unable to add window -- token null is not valid; is your activity running? (tistory.com)

 

[ Android / Kotlin ] AlertDialog 오류 : Unable to add window -- token null is not valid; is your activity running?

AlertDialog를 사용하며 android.view.WindowManager$BadTokenException:Unable to add window -- token null is not valid; is your activity running? 이런 오류를 겪었습니다. 당연하게도 갓구글..

gyubgyub.tistory.com

 

참고자료