Hi Andrew, The answers you got are correct. You should spend as little time in onSaveInstanceState (or any other onXXXXX callback method) as possible. Preferably a few milliseconds.
I don't know what your app does, but it looks like you try to save user supplied information (either in a file or online) and you chose the onSaveInstanceState callback to do so. Don't use this callback for this purpose. The onSaveInstanceState should only be used to enable you to recreate the activity (i.e. what's on the screen) later exactly as it appeared just before its process got killed. No more, no less. This means, as Magouyaware said, saving nothing more than simple values from Views/controls/etc. If you need to persist user-provided data (on file, online), then use another mechanism. If saving this user-provided data could take a relative long time, use a service (Service, better would be IntentService and if you're paranoid a wakefull IntentService - ask Mark about this one :-) - is even better). On Friday, July 20, 2012 8:06:40 AM UTC-4, Andrew wrote: > > I'll try to find this out through experiments. > Yes, I agree that this probably is freezing UI. But there's a problem > here: this cannot be run on a spawned thread as OS may kill the process > right after this call returns, thus, again, killing the saving thread in > the middle! > > On Thursday, July 19, 2012 5:06:10 PM UTC-4, Mark Murphy (a Commons Guy) > wrote: >> >> On Thu, Jul 19, 2012 at 5:00 PM, Andrew wrote: >> > So, basically the limit is ANR limit, correct? >> >> That's my guess. It's a guess, though. >> >> And, bear in mind that the ANR limit is merely the limit where Android >> will take action to stop the bleeding. Your UI should be completely >> frozen during these "several seconds", which is very bad for UX. >> Anything taking that amount of time needs to be done in a background >> thread (e.g., AsyncTask). >> >> -- >> Mark Murphy (a Commons Guy) >> http://commonsware.com | http://github.com/commonsguy >> http://commonsware.com/blog | http://twitter.com/commonsguy >> >> _The Busy Coder's Guide to Android Development_ Version 3.8 Available! >> > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en