How can I ensure that a network call is not executed on the main thread using a handler?

257 Views Asked by At

I am getting an exception (android.os.NetworkOnMainThreadException) when using Handler handler = new Handler(Looper.getMainLooper()); handler.post(runnable);. The runnable includes a network call (closing a socket). What is the difference between handler and an async handler? not sure if that could be handy here.

0

There are 0 best solutions below