AsyncTask is a background process that easily handle UI without handler.You must know that why we use background process. We need background process / multi threading for long processes like communicate with Internet or database. If you handle Multi Threading smartly then your mobile application should perform better.
This article will describe Android thread example:- Multi threading, Processes and Threads in Android application development: In Android every programm (application) have a main thread. We can’t do long processing in main thread. Long processes like communicate with Internet, parse long data or communicate with database etc.
This exception occurs when you write network code on main thread (UI thread). It will throw following exception android.os.NetworkOnMainThreadException Solution:-