Hey guys,

Trying to do the first part of the challenge. With the help of google I thought I had figured it out. So at the beginning and in the constructor I put a

public BoxDrawingView(Context context, AttributeSet attrs) { super(context, attrs); super.setSaveEnabled(true);

and then at the the very end I put

protected Parcelable onSaveInstanceState() {

    Bundle bundle = new Bundle();
    bundle.putParcelable("instanceState", super.onSaveInstanceState());
    Log.i(TAG, "saved instance state");

    return bundle;

  protected void onRestoreInstanceState(Parcelable state) {

    if (state instanceof Bundle) {
      Bundle bundle = (Bundle) state;
      Log.i(TAG, "returning instance state");



However, neither the Logs are being detected in debug so it seems that neither onSaveInstanceState nor onRestoreInstanceState are being called. So I was wondering what I was missing here.


setSaveEnabled(true) isn’t necessary. The missing piece of the puzzle here is that your view must have an id to save instance state. Otherwise, Android has no way to keep track of which view the instance state belongs to.

I’ll add a note to the errata.