Android: isn't saveInstanceState called too often?

In my activity saveInstanceState is called when I move to the next activity (ex.: activity A starts Activity B and activity A's saveInstanceState is called) - is it normal behaviour? As far as I understand (from documentation), saveInstanceState is called when OS shuts down process to reclaim resources.

Answers


Whenever your activity disappears from the screen, the state will be saved for further representations. Say you perform a screen orientation change. As you might know, whenever this happens the view is recreated completely. The way Android does it to keep the state of things is to save the state before destroying and re-creating.


As far as I understand (from documentation), saveInstanceState is called when OS shuts down process to reclaim resources.

No. It is called in any activity transition where there is a chance that Android will want to destroy your activity, yet want to recreate that activity and have it look like it had never been destroyed. The common case is a configuration change (e.g., rotate the screen), but it will come up in other cases as well.

In particular, Android cannot wait until "OS shuts down process to reclaim resources", because by then, Android may be in a serious hurry to get those resources.


Need Your Help

Blocking dialogs in .NET WebBrowser control

c# .net winforms activex mshtml

I have a .NET 2.0 WebBrowser control used to navigate some pages with no user interaction (don't ask...long story). Because of the user-less nature of this application, I have set the WebBrowser

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.