Reputation: 338
I'm very sorry for i explained like fool...
I mean I can't compile because of error.
public class PictureBean implements Serializable
{
public enum CCLtype implements Serializable
{
BY, ND, CO, NN, SA
}
private String picture_rm;
private String picture_url;
private String picture_16_9_url;
private String author;
private String title;
private String description;
private String p_memo;
private String p_original_rate;
private String move_url;
private int like_count;
private int picture_exp_count;
private List<JsonObject> tagList;
private List<JsonObject> categoryList;
private CCLtype ccl;
private String picture_source;
private boolean isUserLiked;
private boolean isUserAdded;
I use this PictureBean.class for contain image datas in my server.
but when I send list of PictureBean data to activity from activity, like below, Eclipse occurred error line.
How could I send list of PictureBean to activity from activity?
'mItems''s dataType is List of PictureBean.
intent.putExtra(CategoryDetailPagerActivity.EXTRA_DATA_CATEGORY_DETAIL_LIST, mItems);
Upvotes: 1
Views: 68
Reputation: 24195
Update:
Don't put the list it self as an extra. send a class object that contain the list as the only member as follow:
public class SerialObject implements Serializable
{
private static final long serialVersionUID = -3975620301776205681L;
public List<PictureBean> myItems;
}
SerialObject sb = new SerialObject();
sb.myItems = mItems;
intent.putExtra(CategoryDetailPagerActivity.EXTRA_DATA_CATEGORY_DETAIL_LIST, sb);
Original Answer:
This is how your class should be:
public class PictureBean implements Serializable
{
private static final long serialVersionUID = 6969933524911660214L;
public enum CCLtype
{
BY, ND, CO, NN, SA
}
private String picture_rm;
private String picture_url;
private String picture_16_9_url;
private String author;
private String title;
private String description;
private String p_memo;
private String p_original_rate;
private String move_url;
private int like_count;
private int picture_exp_count;
private List<JsonObject> tagList;
private List<JsonObject> categoryList;
private CCLtype ccl;
private String picture_source;
private boolean isUserLiked;
private boolean isUserAdded;
}
Same thing for the JsonObject class.
I believe that you don't have to serialise CCLtype
Upvotes: 1
Reputation: 2223
Just a guess because you've not yet posted the error, but as the Android docs say "if the local serialVersionUID differs from the serialVersionUID in the serialized data, deserialization will fail with an InvalidClassException." You can work around this, as I had to in my app, by declaring an explicit ID. Put this in your class, to do so, with any Long
value you like:
private static final long serialVersionUID = 0L;
Upvotes: 1
Reputation: 162
Can you share the error with us? That would be most helpful. Without that information it'd be hard to tell, but my guess is maybe that some of the class types you are trying to make serializable are not types that you can serialize in Android (at least not using the pre-made "Serializable" implementation.
Try commenting out all the types and one at a time uncommenting to find out which type is breaking your serialization. You might be able to write a special serialization method for those types (or switch it to a different type).
Upvotes: 1