I have a class that contains data i want to pass it between intents, this class have arraylist that contains another class objects. this is my class
public class ParsedData implements Parcelable {
public String error;
public float protectionLevel;
public int protectionLevelColor;
public double lastBackup;
public boolean compressedType;
public Long driveFreeSpaceSize;
ArrayList<Item>Items = new ArrayList<Item>();
}
class Item {
public String name;
public float percentage;
public int files;
public long size;
}
how can i send this class between intents ?
i have found the answer after all. thanks all how helped me this is the answer:
and in the caller activity
in the called activity(BreakDownBarActivity in my case)
This may be your problem:
Alternatively, I'd try to have
Item
implementParcelable
, as well.The fail-safe alternative is to write your data structure into a JSON string, which also allows you to pass the data to other applications that don't have access to your
ParsedData
class.you can let your
class Item
implements theSerializable
interface, and use Intent.putExtra(String, Serializable). SinceArrayList
implements also theSerializable
interface, you can pass the wholeItems
object.You may take a look at Intent.putExtra(String name, Parcelable object) and implement the parcelable interface in your class.