Can you tell me how to solve this? It throws a bad array length exception and after debugging, I found this method throws the Exception:
--------------------------My Code-----------------------------------
public class SingleModels implements Parcelable{
public String name;
public String[] names ;
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(name);
dest.writeStringArray(names);
}
public static final Parcelable.Creator<SingleModels> CREATOR = new Creator<SingleModels>() {
@Override
public SingleModels[] newArray(int size) {
return new SingleModels[size];
}
@Override
public SingleModels createFromParcel(Parcel source) {
SingleModels models = new SingleModels();
models.name = source.readString();
models.names = source.createStringArray();
source.readStringArray(models.names);
return models;}
};
}
This is my exception, but so long, I can't upload the image, I cut the information by important:
07-07 09:52:59.319: E/AndroidRuntime(4296): FATAL EXCEPTION: main
07-07 09:52:59.319: E/AndroidRuntime(4296): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.single.parcelable.example/edu.single.parcelable.example.ArrayParcelable_Activity}: java.lang.RuntimeException: bad array lengths
07-07 09:52:59.319: E/AndroidRuntime(4296): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)