Reputation: 1478
This is my code:
//.___ Async task bring info from API __./
AsyncTask asyncTask = new AsyncTask() {
@Override
protected Object doInBackground(Object[] objects) {
mMovieDto = mDataSource.getPopularMovies();
return null;
}
@Override
protected void onPostExecute(Long result) {
fillList();
}
};
asyncTask.execute();
I'm getting the error that the onPostExecute
is not overriding from super, witch is the right way to add this king of method to my AsyncTask
?
Thanks for the help Jose
Upvotes: 0
Views: 61
Reputation: 32790
You are missing the AsyncTask's generic types:
The three types used by an asynchronous task are the following:
- Params, the type of the parameters sent to the task upon execution.
- Progress, the type of the progress units published during the background computation.
- Result, the type of the result of the background computation.
Not all types are always used by an asynchronous task. To mark a type as unused, simply use the type Void:
private class MyTask extends AsyncTask<Void, Void, Void> { ... }
Change your code like this:
AsyncTask asyncTask = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
mMovieDto = mDataSource.getPopularMovies();
return null;
}
@Override
protected void onPostExecute(Void result) {
fillList();
}
};
asyncTask.execute();
Upvotes: 3