5

There are three different implementations of an AsyncTask:

public class DownloadTask extends AsyncTask<String, Integer, Boolean>
public class JsonParserTask extends AsyncTask<Object, Void, Boolean>
public class PostCommentTask extends AsyncTask<String, Void, HttpRequestResult>

I would like them to extend a BaseAsyncTask which I can use for dependency injection then. The class signatur of AsyncTask looks like this:

public abstract class AsyncTask<Params, Progress, Result>

How can I extend AsyncTask while maintaining the different parameters?

                               | DownloadTask
AsyncTask <-- BaseAsyncTask <--| JsonParserTask
                               | PostCommentTask
JJD
  • 50,076
  • 60
  • 203
  • 339

1 Answers1

13

Try:

abstract class BaseAsyncTask<Params, Progress, Result> 
                  extends AsyncTask<Params, Progress, Result>
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491