2

This is a simple doubt of me.

I had a android application with 10 activities. There is some web connection from each activities. So each and every activity I wrote a ASYNC Task for connecting to web service.

Instead of that is there is any method for a common class which handle the webservice and return the data available ?

Something like this ( rough )

My Activity -> Create a JSON for sending to server -> Call the WebserviceClass -> Send those JSON to that webservice Class -> Webservice will read the JSON -> Send to Server -> Return the status / result ( JSON) to "My Activity" -> Parse the JSON and so on ....

By this I can control all the webservice functionality with a single class

I am very new to android app development and please help me

Thanks in advance

ramesh
  • 4,008
  • 13
  • 72
  • 117

2 Answers2

1

Google just released a new networking library called Volley made for just that! I think you will find it suitable to your needs (except if you want to download very big files, then use the DownloadManager)

You can find the GIT clone url here to get the project

Look at this link for examples on how to use it

the-ginger-geek
  • 7,041
  • 4
  • 27
  • 45
  • 1
    Hi @ramesh I haven't used it yet, just saw it on Google IO. There are a bunch of examples out there. I edited my answer with a example link – the-ginger-geek Jun 04 '13 at 07:11
0

If you are doing only rest, in my opinion you could use http://square.github.io/retrofit/ which is really easy to use.

Also Volley as suggested by Neil is good, but a bit more complicated to use for your use case and mostly undocumented. You can find an example application they released here https://github.com/evancharlton/folly

alex
  • 3,412
  • 2
  • 28
  • 36