我收到以下错误,我认为这意味着我的活动为空
fragment not attached to activity on volley response
我如何解决这个问题?这些是我的代码
MainActivity._MainActivity_.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity._MainActivity_, "inserted", Toast.LENGTH_SHORT).show();
}
});
Activity activity = getActivity();
if(activity != null){
Intent mainIntent = new Intent(define, SaveNewFactor.class);
startActivity(mainIntent);
}else {
Log.i("myLog","activity is null");
}
我的logcat图像
我没有在你的代码中看到你的片段…
但我想…也许你的网络响应来得太晚了,在你的片段分离之后
更改意图以启动活动SaveNewFector. class
Intent intent=new Intent(SheetSaveNewFector.this,SaveNewFector.class);
startActivity(intent);