Created
August 28, 2015 13:20
-
-
Save survivingwithandroid/4730c532f8010c20479b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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