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
异常。有人能说一下问题是什么吗?我的目的是将从一个活动下载的图像字节传输到另一个活动中。
dest.writeInt(_byte.length); dest.writeByteArray(_byte);
,在读取时..._byte = new byte[in.readInt()]; in.readByteArray(_byte);
- nEx.Software