Skip to content

Instantly share code, notes, and snippets.

@ibrahim4851
Last active May 22, 2021 12:16
Show Gist options
  • Save ibrahim4851/61ea8f2a0befefba42313531dabdbdbc to your computer and use it in GitHub Desktop.
Save ibrahim4851/61ea8f2a0befefba42313531dabdbdbc to your computer and use it in GitHub Desktop.
VolleyGetArray
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