Reputation: 1263
So I have a class that extends fragment
public class General_Fragment extends Fragment{
int i;
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
outState.putInt(INTEGER_KEY, getInt());
super.onSaveInstanceState(outState);
}
public int getInt(){
return i;
}
…
}
And another class that extends this first class.
public class Specific_Fragment extends General_Fragment{
int j;
@Override
public int getInt(){
return j;
}
…
}
When the Specific Fragment is destroyed the General_Fragments onSavedInstanceState should be called correct? Or do I need to implement something in the subclass to call the superclass method?
Upvotes: 0
Views: 124
Reputation: 1516
No you don't need to override it to be called, it's inherited from its parent class which is General_Fragment
Upvotes: 0
Reputation: 3070
If you do not override the onSaveInstanceState
method in Specific_Fragment
, the one implemented in General_Fragment
will be called.
So there's no need to override it, as long as you don't need to save something else that from the most derived fragment.
Upvotes: 0