Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. public class Config {
  2. public static final String DATA_URL = "http://192.168.33.203/obs/json.php";
  3.  
  4. public static final String TAG_USERNAME = "username";
  5. public static final String TAG_NAME = "name";
  6. public static final String TAG_PASSWORD= "password";
  7. public static final String TAG_ID = "id";
  8.  
  9. //JSON array name
  10. public static final String JSON_ARRAY = "result";
  11. }
  12.  
  13.  
  14. private void getData(){
  15. StringRequest stringRequest = new StringRequest(Config.DATA_URL,
  16. new Response.Listener<String>() {
  17. @Override
  18. public void onResponse(String response) {
  19. JSONObject j = null;
  20. try {
  21.  
  22. j = new JSONObject(response);
  23.  
  24. result = j.getJSONArray(Config.JSON_ARRAY);
  25.  
  26. getUser(result);
  27. } catch (JSONException e) {
  28. e.printStackTrace();
  29. }
  30. }
  31. },
  32. new Response.ErrorListener() {
  33. @Override
  34. public void onErrorResponse(VolleyError error) {
  35.  
  36. }
  37. });
  38. RequestQueue requestQueue = Volley.newRequestQueue(this);
  39.  
  40. requestQueue.add(stringRequest);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement