import android.os.Parcel;
import android.os.Parcelable;
public class MClass implements Parcelable {
private byte[] _byte;
public MClass() {
}
public MClass(Parcel in) {
readFromParcel(in);
}
public byte[] get_byte() {
return _byte;
}
public void set_byte(byte[] _byte) {
this._byte = _byte;
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int flags) {
dest.writeByteArray(_byte);
}
public void readFromParcel(Parcel in) {
in.readByteArray(_byte); //LOE - Line Of Exception
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public MClass createFromParcel(Parcel in) {
return new MClass(in);
}
public MClass[] newArray(int size) {
return new MClass[size];
}
};
}
每当我要检索下面数组中的字节时,它都会返回NullPointerException
异常。有人能说出问题出在哪里吗?我尝试做的是将下载的图像字节从一个活动传输到另一个活动。
发布于 2016-12-07 21:40:43
不存储字节数组长度的更短的解决方案:
dest.writeByteArray(byteArray);
byteArray = in.createByteArray();
https://stackoverflow.com/questions/11708945
复制相似问题