1

what is the best way to call the webservice of long run in android. Calling via Service or Calling via AsyncTask or is there any other suggested best way?

Thanks in advance

user3226628
  • 119
  • 1
  • 6
  • what do you mean by "call the webservice of long run"? Please include enough detail to support your question. – Paresh Mayani Apr 16 '14 at 06:01
  • Since your question is not rich enough to make thoughts , you could choose any of them according your need from this link , http://crazyaboutandroid.blogspot.in/2011/12/difference-between-android.html – dharmendra Apr 16 '14 at 06:06

3 Answers3

0

It depends on for what the web service is called, i.e, if the response being delayed doesn't affect the running of application, it is always good to add it in AsnycTask.

NKB
  • 651
  • 5
  • 13
0

For long running services you can use AsyncTasks or Threads. AsyncTask is very flexible. You can use doInBackground() for background operations. On postExecute() function to update the UI with the results got from the doInBackground().

more here

Community
  • 1
  • 1
Top Cat
  • 2,473
  • 3
  • 22
  • 34
0

If you're seeking understanding, try it both ways. When experimenting with your own AsyncTasks, try confining them to a method that take a callback interface and see how much cleaner it makes the rest of your code.

If you're seeking a practical solution, I highly recommend using a library like android-async-http that handles everything for you.

Kevin Krumwiede
  • 9,868
  • 4
  • 34
  • 82