Created
March 26, 2017 01:49
-
-
Save xxhdpi/95dd2c3724491fd7530ab8bb646ec43e 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
| /** | |
| * 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