내부 클래스 Parcelable을 작성하여 해당 유형의 객체를 AIDL을 통해 원격 서비스에 전달할 수있는 방법을 알아야합니다. 이것에 대한 어떤 정보도 찾을 수 없습니다.내부 클래스를 작성하는 방법 Parcelable
여기에 내가 달성하려는 예제 코드가 있지만 Bar 클래스의 CREATOR가 정적이 될 수 없기 때문에 (즉, 내부 클래스에 있기 때문에) 컴파일되지 않습니다. Bar를 정적 내부 클래스로 만들 수는 없으며 Bar를 Foo 클래스 외부로 이동할 수 없습니다 (시스템 내의 다른 종속성). 또한 AIDL 파일에서 Bar 클래스를 참조하는 방법을 알아야합니다. 어떤 도움이라도 대단히 감사합니다.
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>()
{
...
}
}
}
당신이 당신을 도울 것입니다 http://stackoverflow.com/questions/35923039/android-implementing-parcelable-inner-class에 좀 걸릴 수 있습니다 :
는 여기에 몇 가지 코드 앞의 예입니다. – chaitanya
이 솔루션을 살펴보십시오. 도움이 될 것입니다. http://stackoverflow.com/questions/35923039/android-implementing-parcelable-inner-class – chaitanya