5-10 seconds is way too long to pause (you will easily cause your app to
ANR).  There really should be no reason for most things to take that long,
so the first thing I would do is look at your code.  (And if when say
serialization, you actually mean Java serialization, then the first thing to
do is not use that.)  If you really really can't avoid taking so long to
write your state, then about the only thing you can do is start a service
that then spawns a thread and remains running until the thread is done
writing.  And of course you will need to deal with all of the nasty
threading issues that arise there.

On Mon, Jul 27, 2009 at 6:56 PM, rukiman <[email protected]> wrote:

>
> Finally after many days of getting StackOverflowError, I've tracked
> down the issue and fixed it, only to find that my game's serialization
> takes about 5 -10 seconds on the emulator and most likely around that
> in the target.
>
> So far my the lifecycle of my game is as follows
>
> onCreate - check if serialization file exists, if it does, de-
> serializes it.  (~ 5-10 seconds)
> onPause - if the game is not complete, then serialize it   (~ 5-10
> seconds)
>
> I remember reading somewhere that another activity's onResume will NOT
> get called UNTIL the previous activity's onPause has ended. So I am
> worried that my game is delaying another activity that wants to start
> from doing so i.e like a phone call etc.
>
> I think speeding up the serialization is not going to be feasible, so
> any ideas on what I can do? Can I serialize in the onDestroy instead
> of the onPause? I read that the onPause is the only safest place to
> store the state.
>
> Thanks.
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to