Last Updated: February 25, 2016
·
781
· nischee

Never run a network call on a UI thread

Network calls take time and may cause a delay

7 Responses
Add your response

Also, please try to avoid disk I/O on a UI thread as well :)

over 1 year ago ·

Async right?

over 1 year ago ·

@drabiter Async ??? any network calls may cause a delay...earlier versions of android allowed this, but newer versions will throw a "network on main thread" exception

over 1 year ago ·

@dpashkevich Yes I/O calls too may take time hampering user experience!!!

over 1 year ago ·

@nischee I mean, Async class as the solution :)

over 1 year ago ·

@drabiter yes Async class is a solution!!! :)

over 1 year ago ·

In Android 4 it is not possible to execute network calls in UI thread because system throws NetworkOnMainThreadExteption. :)

http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html

over 1 year ago ·