Last active
May 22, 2021 12:16
-
-
Save ibrahim4851/61ea8f2a0befefba42313531dabdbdbc to your computer and use it in GitHub Desktop.
VolleyGetArray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun getJsonArray() { | |
val requestQueue: RequestQueue = Volley.newRequestQueue(this) | |
val jsonArrayRequest = | |
JsonArrayRequest("https://raw.githubusercontent.com/ibrahim4851/VolleyRequests/master/jsonarray.json", | |
{ response -> | |
for (i in 0 until response.length()) { | |
try { | |
val jsonObject = response.getJSONObject(i) | |
val title = jsonObject.getString("title") | |
val description = jsonObject.getString("description") | |
Log.i("title:", title) | |
Log.i("description:", description) | |
} catch (e: JSONException) { | |
e.printStackTrace() | |
} | |
} | |
}) { | |
Log.i("error", "Connection Error") | |
} | |
requestQueue.add(jsonArrayRequest) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment