Activity.onSaveInstanceState() public or protected?


#1

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?


#2

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

http://stackoverflow.com/questions/215497/in-java-whats-the-difference-between-public-default-protected-and-private/215505#215505


#3

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?