Last active
December 21, 2015 17:58
-
-
Save peter279k/a5248ee2471238fbd497 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 requestWeb() throws Exception { | |
url = "http://google.com"; | |
Request request = new Request.Builder().url(url).build(); | |
client.newCall(request).enqueue(new Callback() { | |
@Override | |
public void onFailure(Request request, IOException e) { | |
Log.e("onFailure", "onFailure exception happened"); | |
e.printStackTrace(); | |
} | |
@Override | |
public void onResponse(final Response response) throws IOException { | |
if(response.isSuccessful() == false) | |
resultStr = "unexpected code: " + response; | |
else | |
resultStr = response.body().string(); | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
responseTxt.setText(resultStr); | |
} | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment