I need to know how to make an inner class Parcelable so that objects of its type can be passed via AIDL to a remote service. I cannot find any information on this.
Here is example code of what I am trying to accomplish, but it doesn't compile because the CREATOR in the Bar class cannot be static (ie because it's in an inner class). I cannot make Bar a static inner class and I cannot move Bar outside of the Foo class (other dependencies within the system). I also need to know how I would reference the Bar class from within an AIDL file. Any help is greatly appreciated.
public class Foo implements Parcelable
{
private int a;
public Foo()
{
}
public Foo(Parcel source)
{
this.a = source.readInt();
}
public int describeContents()
{
return 0;
}
public void writeToParcel(Parcel dest, int flags)
{
dest.writeInt(this.a);
}
public static final Parcelable.Creator<Foo> CREATOR
= new Parcelable.Creator<Foo>()
{
...
}
public class Bar implements Parcelable
{
private int b;
public Bar()
{
}
public Bar(Parcel source)
{
this.b = source.readInt();
}
public int describeContents()
{
return 0;
}
public void writeToParcel(Parcel dest, int flags)
{
dest.writeInt(this.b);
}
public static final Parcelable.Creator<Bar> CREATOR
= new Parcelable.Creator<Bar>()
{
...
}
}
}