In my application I need to call a web service to get some data from the internet. To avoid blocking the UI I use an AsyncTask to do that. But I'm having problems to pass the return value correctly for further use. I guess I'm making some architectural mistakes here. So this is how my application is/should be structured:
MainActivity: An Activity containing a TextView, a Button and a SoapParser (see below). I want to call the web service by pressing the Button, parse the result and display it in the TextView.
SoapRequestTask: An AsyncTask with a callback mechanism like this. The return value of doInBackground() is a SoapObject and is passed to the listener as a parameter in the callback method listener.onTaskCompleted(SoapObject) in onPostExecute().
SoapRequestManager: A class that should have a method public SoapObject makeRequest(someParams). This method is supposed to use my AsyncTask and return my SoapObject from its doInBackground().
MySpecialRequestManager: Extends SoapRequestManager and has different methods to call the web service for different results. Each of these methods uses makeRequest(someParams) of the superclass.
SoapParser: A class that parses a SoapObject to a String so it can be displayed in my Activity's TextView. It should have a method like public String parseResult(SoapObject).
How do I use the callback and the return value correctly? Which class should implement the callback interface?