I am trying to send an array list of objects in another activity. I have checked many articles on this topic and i am using parcelable but i am stuck at point where i cannot send the object.I have tried many things.This is the thing i am trying.
public class ParcalableForm implements Parcelable {
private ArrayList<form> from;
public ParcalableForm (ArrayList<form> choices) {
this.from = choices;
}
public ParcalableForm (Parcel parcel) {
this.from = parcel.readArrayList(null);
}
@Override
public int describeContents() {
return 0;
}
// Required method to write to Parcel
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeList(from);
}
// Method to recreate a Question from a Parcel
public static Creator<ParcalableForm> CREATOR = new Creator<ParcalableForm>() {
@Override
public ParcalableForm createFromParcel(Parcel source) {
return new ParcalableForm(source);
}
@Override
public ParcalableForm[] newArray(int size) {
return new ParcalableForm[size];
}
};
}
This is the parcelable class that implements Parcelable.I am trying to send Arraylist of form to another activity.
Intent i = new Intent(UserPage.this,Form.class);
Bundle extras = new Bundle();
System.out.println("I found a form :- ");
ParcalableForm p=new ParcalableForm(f1.attr);
i.putExtra("geopoints", p);
startActivity(i);
This is the class which is sending the object to the other activity.
Bundle extras = getIntent().getExtras();
ParcalableForm po = new ParcalableForm(extras.getParcelableArrayList("geopoints"));
This is the part where i don't know how to get the object/Arraylist.I have tried many methods but no luck.Any ideas?