안드로이드

Android [Unable to add window, token null is not valid. is your activity running?]

AlertDialog 를 생성할 때 getApplicationContext()를 사용하면 에러가 납니다.

이때는[Activity이름].this 로 변경하면 해결됩니다.

다음은 예시입니다.

AlertDialog.Builder b = new AlertDialog.Builder(ConfigDeviceTypeChoiceActivity.this);
b.setTitle("등록 성공");
b.setMessage("성공적으로 등록하였습니다.");
final AlertDialog alert = b.create();
alert.show();

답글 남기기

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.