Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Example from documentation :
OkHttpClient client = new OkHttpClient();
String run(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
As you have already been answered, you are not fulfilling the request. But, even after you write:
Android will throw an exception that network requests cannot be made on the UI thread.
You need to use at least AsyncTask.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question