how can we parcel nested object in an intent?.
For example
lets say there is an object A which contain one string variable and one another object B. now B contain object C . C contain a list of string. so how i can parcel object A in an intent.
any help on this will be appreciated.
thanks in advance.
Implementation:
public static class A
{
private B ObjectB;
}
public static class B
{
private String type;
private List<C> C;
}
public static class C
{
private List<D> D;
}
public static class D
{
private String id;
private String name;
private String address;
private String email;
}
how to write parcelable for class C.
i am using
dest.writeParceable(ObjectC,flag)
For reading:
in.readParcelable(C.getClass().getClassLoader());
but its not working
You would have to implement parcelable for object B and then implement parcelable for object A. I have never done this but the above should work.
Edit
See the code snippets below which illustrates how to implement parcelable for Class C.
First implement parcelable for Class D like so:
Then implement parcelable for Class C as follows:
This is untested code as I have never implemented nested parceling but worth a try. Hope that helps.