Network Requests with Volley

Consider Volley a 2.0 version of Android Asynchronous Http Client.

A major advantage of Volley over ASyncTask is that you can do multiple requests simultaneously without the overhead of thread management.

Gradle

Add

implementation 'com.android.volley:volley:1.2.1'

to your module gradle dependencies.

Basic Anatomy of a Volley Request

val queue = Volley.newRequestQueue(context)
val stringRequest = StringRequest(
    Request.Method.GET, url,
    { response ->
        Log.e(TAG, "success")
    },
    {
        Log.e(TAG, "error")
    })
queue.add(stringRequest)