android - How to use network frameworks (volley , okhttp , etc) in libgdx? -
i want load data web using volley or okhttp in libgdx.
how use network frameworks volley or okhttp in libgdx instead of libgdx networking class ?
try add compile 'com.squareup.okhttp:okhttp:2.3.0'
project build.gradle
file example
project(":core") { apply plugin: "java" dependencies { ... compile 'com.squareup.okhttp:okhttp:2.3.0' } }
then can use okhttp in core project here example :
public class okhttptest extends applicationadapter { okhttpclient client = new okhttpclient(); @override public void create() { try { system.out.println(run("http://google.com")); } catch (ioexception e) { e.printstacktrace(); } } string run(string url) throws ioexception { request request = new request.builder() .url(url) .build(); response response = client.newcall(request).execute(); return response.body().string(); } }
Comments
Post a Comment