In many examples I have seen online, AsyncTask
is extended, the constructor is overriden, and super() isn't called. For example, in this answer by hackbod:
static class Worker extends AsyncTask<URL, Integer, Long> {
MyActivity mActivity;
Worker(MyActivity activity) {
mActivity = activity;
}
[...]
}
the new constructor does not call back to the parent's constructor.
There's similar code in this sample project by CommonsWare.
So is this correct? Or should super()
really be called?
The default super constructor is called implicitly if super() is not called explicitly. So there is really no difference at all. I'd use the shorter version (omit super()), which seems to be common practice in Java.
p.s. See also this thread: Default constructors and inheritance in Java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With