gpt4 book ai didi

java - Android运行时错误: Parcel unable to marshal value

转载 作者:太空宇宙 更新时间:2023-11-03 13:50:42 24 4
gpt4 key购买 nike

我已经编写了一个这样的类。但是当我使用它时,这个被覆盖的方法发生了运行时错误

 @Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(synclistener);
}

我的类(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];
}
};
}

位置通知器

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(LocationServic‌​eProvider.java:64)
com.ceylonlinux.multilac.activity.FrmHome.onCreate(FrmHome.java:365)

最佳答案

您正在尝试使用 writeParcel()编写不符合文档中所述要求的对象。您只能将值写入 javadoc 中所述类型的 Parcel。

关于java - Android运行时错误: Parcel unable to marshal value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35424484/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com