Can someone explain why async process required even we have to wait for the results in network calls?
Asked
Active
Viewed 205 times
-3
-
3Because Network and IO operation should be done a worker thread in android . Either you wait for result or Use a Callback interface. Waiting for result here is not means that the UI thread is blocked. Read some of the [answers here](https://stackoverflow.com/questions/6343166/how-do-i-fix-android-os-networkonmainthreadexception). – ADM Apr 19 '19 at 04:39
-
@ADM Thanks for you response – Ramesh Pokharel Apr 19 '19 at 07:26
1 Answers
1
Because if we run network calls on the main thread, it would block the user from using the application. The main thread would be blocked.
If the main thread is not responsive to user events like touch , it would lead to ANR( Application Not Responding ).
Dinesh
- 948
- 6
- 11