我编写了一个这样的类。但是当我使用它时,在这个覆盖的方法中出现了运行时错误
@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);
}
例外:
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)