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

vb.net application works with files dragged onto the exe, but crashes if there's a space in the file's path

vb.net visual-studio-2010 path drag-and-drop

I'm developing an application in vb.net. You drag any type of file onto the exe, and a window pops up with some options for the file, then it saves the file to a different location, works some SQL ...

How to communicate FTP transfer with standalone PHP Server?

php apache ftp ftp-client ftp-server

I have a Ubuntu Server on which I have my Apache and FTP server (I am using Proftpd server). I have a small PHP CMS and for database I am using MySQL server. This was my server side environment. No...