Hello,

I have a small problem, hope you can help me.
I want to pass one object of class A from one Android Activity to
another and I need to use Parcelable (performance and Class loading
issues). My code is similar to the lines listed below:

 class A implements Parcelable {
     private String x;       //other fields here...
     private B b;
     ......
     public void writeToParcel(Parcel out, int i) {
          out.writeString(x);
          out.writeParcelable(b, i);
     }
     public static Parcelable.Creator CREATOR = new Parcelable.Creator
() {
        public A createFromParcel(Parcel in) {
              A result = new A();
              result.x= in.readString();
              result.b = in.readParcelable(getClass().getClassLOader
());
              return result;
        }
     }
  }
  class B implements Parcelable {...}

    // Sending Parcelable ....
   bundle.putParcelable(KEY1, a);
   bundle.putSerializable(KEY2, something);
   bundle.putParcelable(KEY3, otherParcelableObject);

    //Receiving Parcelable...
    @Override
    public void onCreate(Bundle icicle) {
        Bundle receivedBundle = getIntent().getExtras()
        Object o= receivedBundle.getParcelable(KEY3)
        // Problem: "o" is NULL here
        // Debug: receivedBundle.mMap= HashMap{ [something, null],
[Map { [KEY3, other], [null,null] }, KEY2], [KEY1, a] }

If I remove from class A the code that writes B into Parcel,
receivedBundle.mMap has the expected value: HashMap {[KEY1, a], [KEY2,
something], [KEY3, other]}.
Am I doing something wrong or is the parcelization mechanism not
supporting recursive Parcelable entities?

              Thanks in advance,
              Lia.

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