I'm trying to read a List of Strings and I keep having the following error:
with the following Parcelable class:
import java.util.List;
import android.os.Parcel;
import android.os.Parcelable;
public class ActivePolicies implements Parcelable {
private List<String> activePolicies;
public ActivePolicies(List<String> activePolicies) {
this.activePolicies = activePolicies;
}
public List<String> getActivePolicies(){
return activePolicies;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeStringList(activePolicies);
}
public static final Parcelable.Creator<ActivePolicies> CREATOR = new Parcelable.Creator<ActivePolicies>() {
@Override
public ActivePolicies createFromParcel(Parcel in) {
try {
return new ActivePolicies(in.createStringArrayList());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@Override
public ActivePolicies[] newArray(int size) {
return new ActivePolicies[size];
}
};
}
It keeps giving me the exception on createFromParcel()
, but I can't figure out why.
It seems a simple parcelable, but when I'm debugging at readStringList()
from the Parcel class, the list is null.
But when I evaluate the value in createStringArrayList()
before it's returning, the list is there with the expected values.