-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
//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);
Metadata
Metadata
Assignees
Labels
No labels