AsyncTask

Create class MyAsyncTask
private class MyAsyncTask extends AsyncTask<String, Integer, Integer>{
//Init
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
}
//start hide
@Override
protected Integer doInBackground(String... params) {
// TODO Auto-generated method stub
return null;
}
//update result
@Override
protected void onProgressUpdate(Integer... values) {
// TODO Auto-generated method stub
super.onProgressUpdate(values);
}
//finish run
@Override
protected void onPostExecute(Integer result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
}
}

Note:
onPreExecute : this function will run first when class is called.
doInBackground: this method run background so it don't impact OBJECT Ui 
onProgressUpdate: receive args from publishProgress in doInBackground. This method syn UI is running.
onPostExecute: This method is called when method doInBackground done.

SHARE

Nguyễn Văn Duy

  • Image
  • Image
  • Image
  • Image
  • Image

0 comments:

Post a Comment