Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1.  RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
  2.                                 String url="http://www.ip-api.com/json";
  3.  
  4. // Request a string response from the provided URL.
  5.                                 StringRequest stringRequest1 = new StringRequest(Request.Method.GET, url,
  6.                                         new Response.Listener<String>() {
  7.                                             @Override
  8.                                             public void onResponse(String response) {
  9.                                                 JSON json = fromStringToJSON(response);
  10.                                                 if (json.obj != null) {
  11.  
  12.                                                         JSONObject jsonObject = (JSONObject) json.obj;
  13.                                                         try {
  14.                                                             Log.d("timezone", jsonObject.getString("timezone"));
  15.  
  16.                                                          
  17.                                                         } catch (JSONException e) {
  18.                                                             e.printStackTrace();
  19.                                                         }
  20.  
  21.                                                 }    
  22. }
  23.                                         }, new Response.ErrorListener() {
  24.                                     @Override
  25.                                     public void onErrorResponse(VolleyError error) {
  26.  
  27.                                     }
  28.                                 });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement