이 오류는 내 오류 보고서에서 android.view.WindowManager$BadTokenException
가 나타납니다. 일부 기기에서는 예외 만보고되지만 앱은 다운되지 않으며 다른 기기에서는 오류가 발생합니다.
앱이 대화 상자를 표시하는 방법과 관련이 있습니다.
다른 답변은 글로벌 하나와 같이 잘못된 context
이 사용되고 있음을 보여 주지만 제 경우에는 다른 작업의 방법으로 내 활동의 컨텍스트를 전달하고 있습니다.
public class Utils {
이 Utils.noConnection(myActivity.this);
오류 로그처럼 내 활동 방법에 의해 불려
public static void noConnection(Context context){
final CustomAlertDialog alert = new CustomAlertDialog(context, context.getString(R.string.ErrorPastTense), context.getString(R.string.ErrorInternet), context.getString(R.string.OkButton), null);
View.OnClickListener listener = new View.OnClickListener()
{
@Override
public void onClick(View v)
{
int id = v.getId();
switch(id){
case R.id.alertConfirm:
alert.dismiss();
break;
default:
break;
}
}
};
alert.setListener(listener);
alert.show();
}
가 표시하는 방법을 alert.show()
에서 발생하는 등의 예외를 포함 왜? 및 피하는 방법
onCreate() 내에서 Context context = null을 전역 및 컨텍스트 = this로 사용하십시오. Utils.noConnection (context); –