Yes I did mean Java serialization. Any reason why I can't use it
(apart from it being slow) ?
The game has lots of objects in memory and references to objects, it
will be a bit tricky to write my own custom code to serialize hence
why I went with the Java serialization as it
automatically handles serializing only one copy of the object and
marking others as references etc. There might be a better way to do
it, but relatively new at it and couldn't think of an easier way at
the time. To complicate matters most of the game code I am serializing
wasn't written by me.

So if I was to start a service, can I do that in the onPause? What if
my activity received an onPause and was destroy straight away because
the new activity chews too much memory, won't my game data in memory
be lost at the same time? Or will it still remain in memory as the
service has a reference to it?


On Jul 28, 12:47 pm, Dianne Hackborn <[email protected]> wrote:
> 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