Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java : Subclassing AsyncTask

I am trying to subclass the android.os.AsyncTask class generically. I basically just want to add a property to it. The thing is, I still want to be able to use it as an anonymous class.

    import android.content.Context;
    import android.os.AsyncTask;

    public class KAsyncTask extends AsyncTask<Params, Progress, Result> {
        public Context c;

    }

I have tried subclassing it, but I just can't wrap it around my head how I am supposed to do this.

Regards, EZFrag

like image 552
EZFrag Avatar asked Jan 25 '12 11:01

EZFrag


1 Answers

You mean you still want it to be an abstract template class like AsyncTask? The declaration would be:

public abstract class KAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {
    public Context c;

}
like image 117
Reuben Scratton Avatar answered Oct 01 '22 05:10

Reuben Scratton