Reputation: 659
How to pass and get "myobject1" between two activities?
First activity:
private ArrayList<Custom> myobject1 = new ArrayList<Custom>();
...
i.putExtra("myobject1", myobject1);
Second activity:
results =(ArrayList<Custom>) getIntent().getSerializableExtra("myobject1");
Here is my Custom.class :
public class Custom implements Comparable<Custom>{
private String big;
private String small;
public Custom(String n,String d)
{
big = n;
small = d;
}
public String getFirst()
{
return big;
}
public String getSecond()
{
return small;
}
@Override
public int compareTo(Custom o) {
if(this.big != null)
return this.big.toLowerCase().compareTo(o.getFirst().toLowerCase());
else
throw new IllegalArgumentException();
}
}
At this moment I'm getting error: E/AndroidRuntime(8032): java.lang.RuntimeException: Parcel: unable to marshal value
Upvotes: 0
Views: 370
Reputation: 5183
In order to pass a value from an Activity
to another the Class
of the object you try to pass should implement the Parcelable
interface. You can find more info here http://developer.android.com/reference/android/os/Parcelable.html. In case you need anything more specific, please shoot it!
Upvotes: 1