Reputation: 1092
I have coded a class like this.but when i'm using this there is runtime error is occured in this overided method
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(synclistener);
}
Myclass
public class SyncListenEntity implements Parcelable {
private LocationServiceProvider.LocationSyncNotifier synclistener;
public LocationServiceProvider.LocationSyncNotifier getSynclistener() {
return synclistener;
}
public void setSynclistener(LocationServiceProvider.LocationSyncNotifier synclistener) {
this.synclistener = synclistener;
}
public SyncListenEntity() {
}
protected SyncListenEntity(Parcel in) {
synclistener = (LocationServiceProvider.LocationSyncNotifier) in.readValue(LocationServiceProvider.LocationSyncNotifier.class.getClassLoader());
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(synclistener);
}
public static final Parcelable.Creator<SyncListenEntity> CREATOR = new Parcelable.Creator<SyncListenEntity>() {
@Override
public SyncListenEntity createFromParcel(Parcel in) {
return new SyncListenEntity(in);
}
@Override
public SyncListenEntity[] newArray(int size) {
return new SyncListenEntity[size];
}
};
}
LocationNotifier
public interface LocationNotifier {
void onNewLocationArrived(Location loaction, String privider);
}
Exception:
java.lang.RuntimeException: Parcel: unable to marshal value
Caused by: java.lang.RuntimeException: Parcel: unable to marshal value
com.library.gps.SyncListenEntity.writeToParcel(SyncListenEntity.java)
android.app.ActivityManagerProxy.getIntentSender(ActivityManagerNative.java:3835)
com.library.gps.LocationServiceProvider.enableUserTrackingService(LocationServiceProvider.java:64)
com.ceylonlinux.multilac.activity.FrmHome.onCreate(FrmHome.java:365)
Upvotes: 4
Views: 12476
Reputation: 317712
You are trying to use writeParcel() to write an object that does not conform to the requirements stated in the documentation. You can only write values into a Parcel of the types stated in the javadoc.
Upvotes: 3