This is the automatic Parcelable
implementation generated by Android Studio. It somehow, always ignores resultCode
which is of type Integer
public class TestParceable implements Parcelable {
private String message;
private Integer resultCode; //an Integer
protected TestParceable(Parcel in) {
message = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(message);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<TestParceable> CREATOR = new Creator<TestParceable>() {
@Override
public TestParceable createFromParcel(Parcel in) {
return new TestParceable(in);
}
@Override
public TestParceable[] newArray(int size) {
return new TestParceable[size];
}
};
}
On the other hand, if I change the type of resultCode
to int
, the automatic Parcelable
implementation considers it.
public class TestParceable implements Parcelable {
private String message;
private int resultCode; //an int
protected TestParceable(Parcel in) {
message = in.readString();
resultCode = in.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(message);
dest.writeInt(resultCode);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<TestParceable> CREATOR = new Creator<TestParceable>() {
@Override
public TestParceable createFromParcel(Parcel in) {
return new TestParceable(in);
}
@Override
public TestParceable[] newArray(int size) {
return new TestParceable[size];
}
};
Am I missing something here or is this and Android Studio bug?
It's a bug (https://code.google.com/p/android/issues/detail?id=233034) which is fixed for Studio 2.4.