I am creating multiple AsyncTask instances. I would like to create an array of AsyncTask to use these references to cancel the task later on but i am not able to figure out how to create an Array.
private AsyncTask<Integer, Void, Bitmap> mLoadTask;
private void loadTask(final Integer sInt){
mLoadTask = new AsyncTask<Integer, Void, Bitmap>() {
@Override
protected void onPostExecute(Bitmap result) {
...
}
@Override
protected Bitmap doInBackground(Integer... params) {
...
}
};
mLoadTask.execute(sInt);
}
I would like for mLoadTask to be called as an array element i.e one for each new task. Something like this
mLoadTask[sInt].execute(sInt)
Please suggest how to modify my code to achieve something like this or if there is another approach to this which would better suit.