I have a custom ViewGroup extending FrameLayout. On orientation change I need to persist one int value. I'm overriding the onSaveInstanceState()
and
onRestoreInstanceState(Parcelable state)
to keep the old value. My code is given below
@Override
protected Parcelable onSaveInstanceState() {
final Bundle bundle = new Bundle();
bundle.putInt(POSITION, position);
return bundle;
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
mPosition = bundle.getInt(POSITION);
}
super.onRestoreInstanceState(state);
}
But I'm getting a crash.
java.lang.IllegalStateException: Derived class did not call super.onSaveInstanceState()
But if I call super.onSaveInstanceState()
on onSaveInstanceState
how can I return my bundle value?
What is the issue here?
Thanks in advance!!