Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

 

Show the video description

In this video we will use the OkHttp library to make a simple asynchronous HTTP request, download a JSON from a URL and display it in a TextView. For this we will use OkHttp’s enqueue method which executes the network call in a background thread. To update the TextView we will then access our main thread with the runOnUiThread method.

Important LinksAndroidManifest.xmlactivity_main.xmlMainActivity.java

Dependency + instructions:

square.github.io/okhttp/

 

Reqres API:

reqres.in