When requirement is to call Web resource, e.g. HTTP, Android require that the call must be asynchronous using AsyncTask. Below is a sample private class that runs AsyncTask.
import android.os.AsyncTask;
//Instantiating AsyncTask
BackgroundJob backgroundJob = new BackgroundJob();
backgroundJob.execute();
private class BackgroundJob extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... arg0)
{
//Add your code here
return null;
}//do in background
@Override
protected void onPostExecute(Void result) {
//Any update to UI should be done here
}
}//End class
No comments:
Post a Comment