Answer the question
In order to leave comments, you need to log in
How to fix error: "IllegalStateException: closed" when creating JSONObject?
Loading a page online and trying to make it a JSON object. An error occurs:
E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: ru.toster.ru.toster.uggu, PID: 2320
java.lang.IllegalStateException: closed
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onResponse(Call call, Response response) throws IOException {
SQlite sQlite = new SQlite(context);
JSONParser parser = new JSONParser();
String[] groups = null;
try {
JSONArray object = (JSONArray) parser.parse(response.body().string());
} catch (ParseException e) {
e.printStackTrace();
}
if (!sQlite.getGroup().equals(""))
activity.saveRasp(response.body().string().split(sQlite.getGroup()+"\":")[1].split(Pattern.quote("},"))[0]+"}", groups);//.split("]]},\"")[0]+"]]}"
call.cancel();
}
Answer the question
In order to leave comments, you need to log in
https://square.github.io/okhttp/3.x/okhttp/okhttp3...
We read until enlightenment.
The response body can be consumed only once.
And you do it twice.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question