项目报错:Fragment not attached to a context

在Activity重建的时候,假如fragment还在使用诸如context,就会出现这个问题,比如说突然横屏,fragment里面正在访问网络接口,使用了 new ProgressDialog(context, R.style.waitting_dialog);来进行等待,就会崩溃,Fragment not attached to a context。可以在fragment内部,使用isAdded()来判断是否fragment和activity绑定。

你可能感兴趣的:(项目报错:Fragment not attached to a context)