Open Seulin opened 4 years ago
//gradle 추가 : implementation 'com.android.volley:volley:1.1.1' // manifests에 internet permission 허용:
RequestQueue queue = Volley.newRequestQueue(this); String url = "http://192.249.19.251:780/api/locations"; Log.d("dbProcess", url+""); final JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, url, null, new Response.Listener<JSONArray>() { @Override public void onResponse(JSONArray response) { try {Log.d("onrespone", response+""); for (int i = 0; i < response.length(); i++) { JSONObject jsonObject = response.getJSONObject(i); int index = Integer.parseInt(jsonObject.getString("index")); String name = jsonObject.getString("name"); String address = jsonObject.getString("address"); float latitude = Float.parseFloat(jsonObject.getString("latitude")); float longtitude = Float.parseFloat(jsonObject.getString("longtitude")); LocationInfo loc = new LocationInfo(index, name, address, latitude, longtitude); Log.d("dbprocess", loc+""); pull_list.add(loc); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { } }); queue.add(jsonArrayRequest);
//gradle 추가 : implementation 'com.android.volley:volley:1.1.1' // manifests에 internet permission 허용: