Hello Android Developers!

This is a bit complicated to explain (and my first post), so bear with
me please:
I am currently trying to figure out the best way of saving my
application's state in a bundle on the onSaveInstanceState event
(working on a game). My application's state is based on a "world"
class which contains various objects.
Among these objects there is a creature object which contains bitmaps
(Bitmap object)(allowing me to draw the various sprites of the
creature when it's walking with more flexibility and accessibility).

Bit of creature constructor
Java:
          //load creature sprites
          for (int i = 1; i<= _spriteCount; i++){
               //walk left
               try{
                    bitmap = BitmapFactory.decodeResource(resources,
R.drawable.class.getDeclaredField("creature_" i).getInt(null));
               }catch(Exception e){
                    bitmap = null;
               }
               walkImages.add(bitmap);
          }


After looking around for a few hours I found that serializing the
world object (and all its sub-objects) was an acceptable way of saving
it in the bundle. Unfortunately it appears that we can't serialize
bitmaps and considering they're a part of my "creature" I can't seem
to see a workaround.

So here come my questions:
1- Am I doing something fundamentally wrong? (not supposed to save
bitmaps in objects? supposed to handle bitmaps in a separate class
which I don't pass on the bundle and reload my bitmaps when restoring
the application? ...)
2- Is there another way of passing my "world" object into my bundle
(would using Parcelable work?)

I'm not sure what my options are at this point. I hope I was clear
enough; don't hesitate to ask for any (probably needed)
clarifications.

In any case, thanks for reading, any help would be much appreciated.

-- 
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

Reply via email to