Skip to content

Instantly share code, notes, and snippets.

@xxhdpi
Created March 26, 2017 01:49
Show Gist options
  • Select an option

  • Save xxhdpi/95dd2c3724491fd7530ab8bb646ec43e to your computer and use it in GitHub Desktop.

Select an option

Save xxhdpi/95dd2c3724491fd7530ab8bb646ec43e to your computer and use it in GitHub Desktop.
/**
* ambil data dari internet menggunakan StringRequest dari volley
*/
private void getDataFromURL(String url) {
StringRequest stringRequest =
new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override public void onResponse(String response) {
// logging
Log.d(TAG, "onResponse: " + response);
tvHasil.setText(response);
}
}, new Response.ErrorListener() {
@Override public void onErrorResponse(VolleyError error) {
// jika proses http rquest gagal
tvHasil.setText(error.getLocalizedMessage());
}
});
// menambahkan request ke queue
requestQueue.add(stringRequest);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment