I am trying to send a list of objects in another activity. I checked a lot of articles on this topic and I use parsing, but I am stuck at the point where I cannot send the object. I have tried many things. This is what I'm 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;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeList(from);
}
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 a class that implements Parcelable. I am trying to submit an Arraylist form to another action.
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 a class that sends an object to another action.
Bundle extras = getIntent().getExtras();
ParcalableForm po = new ParcalableForm(extras.getParcelableArrayList("geopoints"));
This is the part where I do not know how to get the object / Arraylist. I tried many methods, but no luck. Any ideas?
source
share