๋ฐ์ํ
Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- JavaScript
- ์๋ฐ๊ณต๋ถ
- Android
- ํ๋ค์ค๊ณต๋ถ
- ์๋ฐ์คํฌ๋ฆฝํธ
- ์คํธ๋ฆผ๋ฆฟ
- ์คํธ๋ฆผ๋ฆฟ ๊ธฐ๋ณธ
- ์๋ฐ์คํฌ๋ฆฝํธ ๊ณต๋ถ
- ํ์ด์ฌ๊ณต๋ถ
- Streamlit๊ธฐ๋ณธ
- ์๋ฐ
- ์น๋์๋ณด๋ ๊ธฐ์ด
- ์๋ฐ์ด๋ณด
- ์น๋์๋ณด๋ ์ ์
- ์๋๋ก์ด๋ ์ฑ ๊ฐ๋ฐ
- ์๋ฐํ๋ก๊ทธ๋๋ฐ
- ํ๋ค์ค
- ์๋ฐ๊ธฐ์ด
- MySQL
- Streamlit๊ธฐ์ด
- RESTful API
- serverless
- Matplotlib ๊ธฐ์ด
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
- ํ์ด์ฌ
- Pandas
- db
- java
- ์๋๋ก์ด๋ ์คํ๋์ค
- streamlit
Archives
- Today
- Total
ruriruriya
[Android] ์๋๋ก์ด๋ - JSON ๋ฐ์ดํฐ ํ์ฑํ๋ ๋ฐฉ๋ฒ(Volley) ๋ณธ๋ฌธ
๐คAndroid/Java
[Android] ์๋๋ก์ด๋ - JSON ๋ฐ์ดํฐ ํ์ฑํ๋ ๋ฐฉ๋ฒ(Volley)
๋ฃจ๋ฆฌ์ผใ 2024. 1. 2. 13:04๋ฐ์ํ
Volley ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํ์ฉํด์ ๋คํธ์ํฌ ํต์ ์ ํตํด ๋ฐ์ดํฐ๋ฅผ ๋ฐ๋ ๋ฐฉ๋ฒ์ ์์๋ณด์.
MainActivity.java
1. queue ์์ฑ
๋คํธ์ํฌ ํต์ ์ ํ์ํ queue๋ฅผ onCreate์ ์์ฑ
RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
2. Request๋ฅผ ๋ง๋ ๋ค.
์ด ๋, Response์ ํํ๋ฅผ ํ์ธํ๋ค.
[JSON ์ฉ์ด ์ ๋ฆฌ]
json Array = python List
json (Array)object = python Dict
ํ์ธ ํ ๋ค์ฏ๊ฐ์ง์ ํ๋ผ๋ฏธํฐ๋ฅผ ์์ฑํ๋ค.
JsonArrayRequest request = new JsonArrayRequest(
Request.Method.GET,
"https://jsonplaceholder.typicode.com/posts",
null,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}
);
3. queue์ request ์ถ๊ฐ
queue์ request ์ถ๊ฐํ์ฌ ์คํํ๋ค.
queue.add(request);
๋ฐ์ํ