Skip to content

Instantly share code, notes, and snippets.

@survivingwithandroid
Created August 28, 2015 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save survivingwithandroid/4730c532f8010c20479b to your computer and use it in GitHub Desktop.
Save survivingwithandroid/4730c532f8010c20479b to your computer and use it in GitHub Desktop.
public void doRequest() {
initClient();
Request req = new Request.Builder()
.url(URL)
.get()
.build();
client.newCall(req).enqueue(new Callback() {
@Override
public void onFailure(Request request, IOException e) {
}
@Override
public void onResponse(Response response) throws IOException {
try {
String body = response.body().string();
Log.d("AA", "resp [" + body + "]");
JSONObject obj = new JSONObject(body);
float data = (float) obj.getDouble("temp");
((DataListener) ctx).notifyData(data);
}
catch(Throwable t) {
t.printStackTrace();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment