0

I am making request to web service and have to do this extending AsyncTask for every methods. So how many methods i have in webservice that many classes i need to create in this way.

I found this topic how to make callback: Making Callback

But there are shown one class callback, but what if i want that there would lots of callbacks in one class ?

Community
  • 1
  • 1
Streetboy
  • 4,351
  • 12
  • 56
  • 101

1 Answers1

0

The AsyncTask class has generic parameters for data that is passed between its methods. You can use a custom class to pass the data from one method to other.

Web-service access is usually done in 3 steps :

  1. Retrieving the content (XML/JSON etc.)
  2. Parsing the content
  3. Reading the content.

You can pass the AsyncTask the URL to be fetched (As shown there) In background you can retrieve content and parse it. The reading of content can be done in different code blocks which run on UI thread depending on the result parameter.

Shruti
  • 1
  • 13
  • 55
  • 95
Tech Agent
  • 657
  • 5
  • 12