2

i got a serious problem while trying to unmarshall an ArrayList of custom objects, with an ArrayList of custom objects as a field in it. When i remove everything that has to do with the ArrayList<User> in the Coon.java everything works fine. The error occurs, after including the "readTypedList"-part....Trying to fix that problem the whole day and can't find any solution.

Thanx in advance, Roberto

Stacktrace: http://pastebin.com/LAGYmW95

Code:

->  Coon.java  <-

package development.coonDub.misc;


import java.util.ArrayList;

import android.os.Parcel;
import android.os.Parcelable;

public class Coon implements Parcelable {

/**
 * 
 */


public Coon(Parcel in) {
    readFromParcel(in);

}

String name;
String city;
String country;
ArrayList<User> pts = new ArrayList<User>();

public Coon(String name, String city, String country,ArrayList<User> pts) {
    this.name = name;
    this.city = city;
    this.country = country;
    this.pts = pts;
}



public String getName() {
    return name;
}

public String getCity() {
    return city;
}

public String getCountry() {
    return country;
}
public ArrayList<User> getPts() {
    return pts;
}




@Override
public int describeContents() {
    return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(name);
    dest.writeString(city);
    dest.writeString(country);
    dest.writeTypedList(pts);

}

private void readFromParcel(Parcel in) {
    name = in.readString();
    city = in.readString();
    country = in.readString();        
    in.readTypedList(pts, User.CREATOR);
}

public static final Parcelable.Creator<Coon> CREATOR =
        new Parcelable.Creator<Coon>() {
            public Coon createFromParcel(Parcel in) {
                return new Coon(in);

            }

            public Coon[] newArray(int size) {
                return new Coon[size];
            }
        };
  }

->  User.java  <-
package development.coonDub.misc;

import android.os.Parcel;
import android.os.Parcelable;

public class User implements Parcelable {

String name;

public static final Parcelable.Creator<User> 
CREATOR = new    Parcelable.Creator<User>() {
    public User createFromParcel(Parcel in) {
        return new User(in);
    }

    public User[] newArray(int size) {
        return new User[size];
    }
};

public User(String name) {
    this.name = name;
}

public User(Parcel in) {
    readFromParcel(in);

}

private void readFromParcel(Parcel in) {
    name = in.readString();

}

public String getName() {
    return name;
}

@Override
public int describeContents() {
    return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(name);

}
}

->  Activity1.class  <-
...
Intent notificationIntent = 
new Intent(getApplicationContext(),  Activity2.class);
// coons is an ArrayList<Coon>..
    notificationIntent.putExtra("coons", coons);
...

-> Activity2.class <-
...
ArrayList<Coon> coons = getIntent().getExtras().getParcelableArrayList("coons");
...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.