Search code examples
javaandroidweb-servicesksoap2

ANR when using ksoap2 to send data to web services


I am currently able of sending stuff into a server with ksoap2 library for android. Now I have the need to make sure that this line doesn't block the app and makes it ANR:

androidHttpTransport.call(connection.getSOAP_ACTION(), envelope);

If by any reason i cant reach the server (for example the server is shutdown) this call blocks the app. how can i treat this?


Solution

  • You should run calls like this within an AsyncTask, so it doesn't block the UI Thread.

    Also, you might be interested in this blog article on Painless threading in Android.