How do I use networking frameworks (volley, okhttp, etc.) in libgdx?

I want to download some data from internet using volley or okhttp in libgdx.
How do I use networking structures like volley or okhttp in libgdx instead of the libgdx networking class ?


source to share

1 answer

Try adding this one compile 'com.squareup.okhttp:okhttp:2.3.0'

to your project build.gradle

, for example

project(":core") {
    apply plugin: "java"

    dependencies {
            compile 'com.squareup.okhttp:okhttp:2.3.0'


Then you can use okhttp in your main project, here is an example:

public class OkhttpTest extends ApplicationAdapter {
    OkHttpClient client = new OkHttpClient();

    public void create() {
        try {
        } catch (IOException e) {

    String run(String url) throws IOException {
        Request request = new Request.Builder()

        Response response = client.newCall(request).execute();
        return response.body().string();




All Articles