I\'ve been doing a bunch of research and looking over the documentation for ASyncTask in Android, but I just can\'t seem to wrap my head around it. I simply want to run some
The three types used by an asynchronous task are the following:
Params, the type of the parameters sent to the task upon execution. i.e if you want to send some variable/array to your async task background task. You use that information using that variable.
Progress, the type of the progress units published during the background computation. i.e to show the progress of your background progress. ( such as showing how much a video/image is downloaded)
String[] username;
username[0]="user1"; username[1]="user2";
new asynctask().execute(username);
private class asynctask extends AsyncTask
{
@Override
protected void onPreExecute()
{
// anything you want to do prior starting the async task.
}
@Override
protected String doInBackground(USER... users)
{
int count = users.length;
for (int i = 0; i < count; i++)
retriveinformation(users[i]);
return "Hey";
}
protected void onProgressUpdate(Integer... progress) {
setProgressPercent(progress[0]);
}
protected void onPostExecute(String result) {
// the value result is HEY that is returned by doInBackground.
}
}
Not all types are always used by an asynchronous task. To mark a type as unused, simply use the type Void.
information taken from https://developer.android.com/reference/android/os/AsyncTask.html