I get a NullPointerException when I try to read String[]
when I create an object from Parcel . Here is my code:
@Override public void writeToParcel(Parcel out, int flags) { out.writeInt(floors); out.writeStringArray(indoorMaps); } public static final Parcelable.Creator<Building> CREATOR = new Parcelable.Creator<Building>() { public Building createFromParcel(Parcel in) { return new Building(in); } public Building[] newArray(int size) { return new Building[size]; } }; private Building(Parcel in) { floors = in.readInt(); in.readStringArray(indoorMaps); }
So, innerMaps is an attribute of my class, and this String[]
, but I get an exception NullPointerException. I checked the dev documentation, but there is nothing there. I followed this tutorial and they use readStringArray
.
Any suggestions? Thanks
source share