9dvbmg
Last Updated: February 25, 2016
·
628
· nischee

Never run a network call on a UI thread

Network calls take time and may cause a delay

Say Thanks
Respond

7 Responses
Add your response

5783
D42a7264714dee5006b9c99d2567a320

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

over 1 year ago ·
5785
Dsc 0105 0

Async right?

over 1 year ago ·
5787

@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 ·
5788

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

over 1 year ago ·
5789
Dsc 0105 0

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

over 1 year ago ·
5790

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

over 1 year ago ·
10948
Profile

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 ·