This Question asked in Most Android Exams, but I didn't got any answer from any android forums.
Thanks in advance.
This Question asked in Most Android Exams, but I didn't got any answer from any android forums.
Thanks in advance.
Straight from Android documentation:
To avoid creating an unresponsive UI, don't perform network operations on the UI thread. By default, Android 3.0 (API level 11) and higher requires you to perform network operations on a thread other than the main UI thread; if you don't, a NetworkOnMainThreadException is thrown.
It is never acceptable to make network calls on the UI thread.
Never ever ever ever ever ever ever ever ever ever ever.
Ever.
It's quite literally impossible to do so on Android.
Android itself will throw an exception if you try to do it on the UI thread.
https://developer.android.com/reference/android/os/NetworkOnMainThreadException.html