I am referring the big nerd ranch android book for learning android.
When overriding Activity
or Fragment
methods, I have come across places where the call to super()
is removed, and some places where it is kept as a part of the overriding method.
How can I understand that which methods need the super()
and which don't?
And if the super()
is to be kept... is it always on the first line? I ask this because while searching for an answer, I came across this
public MyCanvas(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
}
On a humble note: I have seen the posts
Android Activity which overridden functions must call super.*
and
Locations of super() calls in Android Eclipse Plugin generated code reliable?
but it didn't clear my doubts. So I hope I am not breaking any rules by posting this question.