0

Currently i am working on an app which require data from web services to update the list View according to that data received. what should i do to fetch that data without letting user know.Should i use Asynchronous Task class or service ,Looking forward to your answers.

1 Answers1

0

Yes, you may use asynchronous task (AsyncTask) to get the data (json) store it in a variable/array and then add it in your listview.

AsyncTask has four steps:

doInBackground: Code performing long running operation goes in this method. When onClick method is executed on click of button, it calls execute method which accepts parameters and automatically calls doInBackground method with the parameters passed. onPostExecute: This method is called after doInBackground method completes processing. Result from doInBackground is passed to this method. onPreExecute: This method is called before doInBackground method is called. onProgressUpdate: This method is invoked by calling publishProgress anytime from doInBackground call this method.

for further details: http://www.compiletimeerror.com/2013/01/why-and-how-to-use-asynctask.html#.UtP-OfQW1QA

Community
  • 1
  • 1
  • Thanks for your advice, but like when the user access the app for the second time i want to show him the data received at 1st time and do the checking for new updates in background without letting him know and after successful update i want to show him the updated list view. – Gourav Kundu Jan 13 '14 at 19:39