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];
}
};
}
Ogni volta che sto per recuperare i byte nel mio seguente array sta tornando eccezione di NullPointerException
. Qualcuno può dire qual è il problema? Quello che sto cercando di fare è trasferire i byte di un'immagine scaricata da un'attività all'altra.Trasferimento ByteArray attraverso parcella restituisce NullPointerException
vuoi dire qualcosa come: public void readFromParcel (Parcel in) { _byte = new byte [length_of_byte]; in.readByteArray (_byte); } – Debopam
In write ... 'dest.writeInt (_byte.length); dest.writeByteArray (_byte); 'e in read ...' _byte = new byte [in.readInt()]; in.readByteArray (_byte); ' –
ok .. fammi controllare .. – Debopam