I have a Parcelable object which I use to pass it from Activity to remote service. When I pass it using AIDL interface, everything sounds fine.
Recently, I try to pass it through Messenger from Activity.
// TEST TEST TEST!
StockInfo stockInfo0 = new StockInfo(Code.newInstance("code0"), Symbol.newInstance("symbol0"));
StockInfo stockInfo1 = new StockInfo(Code.newInstance("code1"), Symbol.newInstance("symbol1"));
StockInfo stockInfo2 = new StockInfo(Code.newInstance("code2"), Symbol.newInstance("symbol2"));
List<StockInfo> stockInfos = new ArrayList<StockInfo>();
stockInfos.add(stockInfo0);
stockInfos.add(stockInfo1);
stockInfos.add(stockInfo2);
StockInfosEx stockInfosEx = new StockInfosEx(stockInfos, "abc");
msg.obj = stockInfosEx;
try {
mService.send(msg);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I'm getting the following exception in remote service.
02-21 22:55:16.546: E/Parcel(8365): Class not found when unmarshalling: com.example.testonmessenger.StockInfosEx, e: java.lang.ClassNotFoundException: com.example.testonmessenger.StockInfosEx
I was wondering, what can get wrong in between? Here is my Parcelable object.
public class StockInfosEx implements Parcelable {
public final List<StockInfo> stockInfos;
public final String searchedString;
public StockInfosEx(List<StockInfo> stockInfos, String searchedString) {
this.stockInfos = stockInfos;
this.searchedString = searchedString;
}
////////////////////////////////////////////////////////////////////////////
// Handling Parcelable nicely.
public static final Parcelable.Creator<StockInfosEx> CREATOR = new Parcelable.Creator<StockInfosEx>() {
public StockInfosEx createFromParcel(Parcel in) {
return new StockInfosEx(in);
}
public StockInfosEx[] newArray(int size) {
return new StockInfosEx[size];
}
};
private StockInfosEx(Parcel in) {
stockInfos = new ArrayList<StockInfo>();
in.readTypedList(stockInfos, StockInfo.CREATOR);
searchedString = in.readString();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeTypedList(stockInfos);
parcel.writeString(searchedString);
}
// Handling Parcelable nicely.
////////////////////////////////////////////////////////////////////////////
}
To get complete source code, kindly download from https://www.dropbox.com/s/n69yuhddpb8vedz/testonmessenger.zip