Java androidruntime error: package cannot Marshal value
•
Android
I have coded such a class. However, when I use this class, runtime errors will occur in this repeated method
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(synclistener);
}
My class
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);
}
Exceptions:
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)
resolvent:
You are trying to write an object that does not meet the requirements described in the document using writeparcel(). You can only write values to parcels of types declared in Javadoc
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码