Activity.onSaveInstanceState() public or protected?


The book uses public void onSaveInstanceState(), but in the android reference I see it’s protected-not public. the @Override notation doesn’t have a problem with public or protected.

Are these the same method? How does this work?


Yes, same method. The only difference is the scope. public has wider scope than protected.


Thank you.

I realized my mistake. The method being overridden is protected, but (for some reason) we were making it public. Is there a reason the authors would tell us to do this? Why not keep it protected?