Now Reading
How to use AsyncTask in Android with simple Example using okHttp ?

This tutorial shows how to work with threads in Android. AsyncTask can be used for the operation like Network Call without interrupting UI thread. This class can be used to perform background operations and casting results on the UI thread without having to manipulate threads and/or handlers to make complications to the application. On Network Calls on UI thread, hence waits for the result and it may crash the application, So the best way to perform background operations using AsyncTask etc..

AsyncTask is done to be a helper class around Handler and Thread and it doesn’t follow a generic threading framework.It can be mainly used for any small operation which can be done a short period of time ie, last for few seconds.

  •  Runs on a background thread and whose result is published on the UI thread.
  • Mainly 3 generic types are required – ParamsProgressResult
  • Mainly 3 methods can be called –


  1. Copy this code and save it in a new Java class file. [ Here class name is  OkHttpHandler, make changes as you want].
  2. Use the below code in your

Please do comment if any doubts….


What's your reaction?
Love It
Like It
Want It
Had It
Hated It
About The Author
Jake Falls
Jake Falls
Jake is an Android enthusiastic. He is obtaining his Bachelors in Computer Science at New York City College of Engineering. Jake understands several programming languages, but his desire for Android started when recognized Android was adequate at sub-par and equipment at app. He is changing Android for six years, creating, and has today been constructing.

Leave a Response