I got a question about an abstract class.
I'm developing an android application and wrote an abstract class which extends the AsyncTask<Void, Fragment, Fragment> class. The doInBackground method has already a body in my abstract class but I don't want to return anything here. Now my subclass that extends that abstract class should override that doInBackground method again, call super, do some work and then return a value.
the method in my abstract class looks like this:
@Override
protected Fragment doInBackground(Void... params) {
//do some work without returning a value
}
and the method in my extending subclass looks like this:
@Override
protected Fragment doInBackground(Void.. params) {
super.doInBackground();
MyFragment fragment = new MyFragment();
//do some work with the fragment
return fragment;
}
So if I do not have a return statement in my abstract class Android Studio flags my method with an "Missing return statement" error. Is there a way to avoid this error message, because my subclass has a return value and so it should be no problem, should it?
Fragment
. That is a UI element. Instead return some data to be displaying within the UI – OneCricketeer