加载捆绑包时出错。我检查了所有的初始化和转换,但无法解决此问题。 请参阅参考资料:
Bundle bundle = getIntent().getExtras();
if (bundle.containsKey("MEASUREMENT_DATA")) {
body_scaleMeasurement = bundle.getParcelable("MEASUREMENT_DATA");
evaluate_info();
}
body _scaleMeasurement的代码
package model;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.annotations.SerializedName;
public class BodyScaleMeasurement implements Parcelable {
@SerializedName("id")
private String id;
@SerializedName("client_platform_version")
private String client_platform_version;
@SerializedName("client_build_number")
@SerializedName("client_platform_data")
private Client_platform_data client_platform_data;
@SerializedName("ble_device_data")
private Ble_device_data ble_device_data;
private transient boolean is_synchronized;
public BodyScaleMeasurement() {
}
public BodyScaleMeasurement(String id, String client_platform_version, int client_build_number, Client_platform_data client_platform_data, Ble_device_data ble_device_data, boolean is_synchronized) {
this.id = id;
this.client_platform_version = client_platform_version;
this.client_build_number = client_build_number;
this.client_platform_data = client_platform_data;
this.ble_device_data = ble_device_data;
this.is_synchronized = is_synchronized;
}
public boolean is_synchronized() {
return is_synchronized;
}
public void setIs_synchronized(boolean is_synchronized) {
this.is_synchronized = is_synchronized;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getClient_platform_version() {
return client_platform_version;
}
public void setClient_platform_version(String client_platform_version) {
this.client_platform_version = client_platform_version;
}
public int getClient_build_number() {
return client_build_number;
}
public void setClient_build_number(int client_build_number) {
this.client_build_number = client_build_number;
}
public Client_platform_data getClient_platform_data() {
return client_platform_data;
}
public void setClient_platform_data(Client_platform_data client_platform_data) {
this.client_platform_data = client_platform_data;
}
public Ble_device_data getBle_device_data() {
return ble_device_data;
}
public void setBle_device_data(Ble_device_data ble_device_data) {
this.ble_device_data = ble_device_data;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.id);
dest.writeString(this.client_platform_version);
dest.writeInt(this.client_build_number);
dest.writeParcelable(this.client_platform_data, 0);
dest.writeParcelable(this.ble_device_data, 0);
dest.writeByte(is_synchronized ? (byte) 1 : (byte) 0);
}
protected BodyScaleMeasurement(Parcel in) {
this.id = in.readString();
this.client_platform_version = in.readString();
this.client_build_number = in.readInt();
this.client_platform_data = in.readParcelable(Client_platform_data.class.getClassLoader());
this.ble_device_data = in.readParcelable(Ble_device_data.class.getClassLoader());
this.is_synchronized = in.readByte() != 0;
}
public static final Parcelable.Creator<BodyScaleMeasurement> CREATOR = new Parcelable.Creator<BodyScaleMeasurement>() {
public BodyScaleMeasurement createFromParcel(Parcel source) {
return new BodyScaleMeasurement(source);
}
public BodyScaleMeasurement[] newArray(int size) {
return new BodyScaleMeasurement[size];
}
};
}
这是我得到的错误。请参阅我附上的图片。
答案 0 :(得分:0)
之所以发生这种情况,是因为我将其他变量的类型从GrowAndShirnk
更改为double
。虽然没有预料到,但我自己并没有低估它。我还原了转换完成的更改。
此外,转换后的值也发生了变化。例如:如果我发送50与密钥捆绑。它被设置为一些负整数。
答案 1 :(得分:-1)
Client_platform_data implements Parcelable
是否有可能
Parcelable.Creator<Ble_device_data>
?