Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am working on android application and in that I want to pass a Cutom list Object to other activity via intent. I have made that CustomList class to implement Serializable interface. and sending the data via intent using the below code:

FeedList mSelectedFeedList = mFeedItemList.get(position);
Intent intent = new Intent(mContext, SingleFeedPage.class);                                         intent.putExtra("feedItemPosition", listItemHolder.mSelectedPosition);
intent.putExtra("action_id", mSelectedFeedList.getmActionId());
intent.putExtra("feedList", mSelectedFeedList);

When I am sending this mSelectedFeedList via intent I am getting the below error:

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.socialengineaddons.mobileapp.classes.common.utils.FeedList)

Below is my code for FeedList.java

public class FeedList {

private String mFeedIcon, mFeedTitle, mFeedPostTime, mWebUrl, mActionTypeBody, mFeedAttachmentType;
private int mAttachmentCount, mLikeCount, mCommentCount, mIsLike, mPhotoAttachmentCount;
private int mCommentAble, mShareAble;
private int mCanComment;
private JSONArray mFeedMenusArray, mFeedAttachmentArray, mFeedFilterArray;
private JSONObject mFeedFooterMenus, mFeedPostMenus,mFeedObject;
String mHiddenBodyText, mUndoHiddenFeedURl, mHideAllText, mHideAllUrl, mHideAllName, mFeedType;
int mSubjectId, mActionId;
Map<String, String> mClickableStringsList;
Map<Integer, String> mVideoInfo;
boolean noFeed;
ArrayList<PhotoListDetails> mPhotoDetails;

public FeedList(int actionId, int subjectId, String mFeedTitle, String mFeedIcon, JSONArray
        mFeedMenusArray, String mFeedPostTime, int attachmentCount, int likeCount, int commentCount,
                int canComment, int isLike, JSONObject feedObject, JSONArray feedAttachmentArray, int photoAttachmentCount,
                JSONObject feedFooterMenus, int commentAble, int shareAble,
                Map<String, String> clickableStrings, String actionTypeBody, Map<Integer, String> videoInfo,
                String url, String feedAttachmentType, String type) {

    this.mSubjectId = subjectId;

    this.mFeedTitle = mFeedTitle;
    this.mFeedIcon = mFeedIcon;
    this.mFeedMenusArray = mFeedMenusArray;
    this.mFeedPostTime = mFeedPostTime;

    mAttachmentCount = attachmentCount;
    mLikeCount = likeCount;
    mCommentCount = commentCount;
    mIsLike = isLike;
    mCanComment = canComment;

    this.mFeedObject = feedObject;
    this.mFeedAttachmentArray = feedAttachmentArray;
    this.mPhotoAttachmentCount = photoAttachmentCount;

    this.mCommentAble = commentAble;
    this.mShareAble = shareAble;

    mFeedFooterMenus = feedFooterMenus;

    mActionId = actionId;

    mClickableStringsList = clickableStrings;
    mVideoInfo = videoInfo;

    mWebUrl = url;
    mActionTypeBody = actionTypeBody;

    mFeedAttachmentType = feedAttachmentType;
    mFeedType = type;

}

public FeedList(JSONObject feedPostMenus, JSONArray FeedFilterArray, boolean isNoFeed){
    mFeedPostMenus =  feedPostMenus;
    mFeedFilterArray = FeedFilterArray;
    this.noFeed = isNoFeed;
}

public boolean isNoFeed() {
    return noFeed;
}

public String getmFeedIcon() {
    return mFeedIcon;
}

public String getmFeedTitle() {
    return mFeedTitle;
}

public String getmFeedPostTime() {
    return mFeedPostTime;
}

public JSONArray getmFeedMenusArray() {
    return mFeedMenusArray;
}

public void setmFeedMenusArray(JSONArray mFeedMenusArray) {
    this.mFeedMenusArray = mFeedMenusArray;
}

public int getmAttachmentCount() {
    return mAttachmentCount;
}

public int getmLikeCount() {
    return mLikeCount;
}

public void setmLikeCount(int mLikeCount) {
    this.mLikeCount = mLikeCount;
}

public int getmCommentCount() {
    return mCommentCount;
}

public void setmCommentCount(int mCommentCount) {
    this.mCommentCount = mCommentCount;
}

public int getmIsLike() {
    return mIsLike;
}

public void setmIsLike(int mIsLike) {
    this.mIsLike = mIsLike;
}

public int ismCanComment() {
    return mCanComment;
}

public int getmPhotoAttachmentCount() {
    return mPhotoAttachmentCount;
}

public JSONArray getmFeedAttachmentArray() {
    return mFeedAttachmentArray;
}

public JSONObject getmFeedFooterMenus() {
    return mFeedFooterMenus;
}

public void setmFeedFooterMenus(JSONObject mFeedFooterMenus) {
    this.mFeedFooterMenus = mFeedFooterMenus;
}

public String getmHiddenBodyText() {
    return mHiddenBodyText;
}

public void setmHiddenBodyText(String mHiddenBodyText) {
    this.mHiddenBodyText = mHiddenBodyText;
}

public String getmUndoHiddenFeedURl() {
    return mUndoHiddenFeedURl;
}

public void setmUndoHiddenFeedURl(String mUndoHiddenFeedURl) {
    this.mUndoHiddenFeedURl = mUndoHiddenFeedURl;
}

public String getmHideAllText() {
    return mHideAllText;
}

public void setmHideAllText(String mHideAllText) {
    this.mHideAllText = mHideAllText;
}

public String getmHideAllUrl() {
    return mHideAllUrl;
}

public void setmHideAllUrl(String mHideAllUrl) {
    this.mHideAllUrl = mHideAllUrl;
}

public String getmHideAllName() {
    return mHideAllName;
}

public void setmHideAllName(String mHideAllName) {
    this.mHideAllName = mHideAllName;
}

public int getmCommentAble() {
    return mCommentAble;
}

public void setmCommentAble(int mCommentAble) {
    this.mCommentAble = mCommentAble;
}

public int getmShareAble() {
    return mShareAble;
}

public void setmShareAble(int mShareAble) {
    this.mShareAble = mShareAble;
}

public int getmSubjectId() {
    return mSubjectId;
}

public void setmSubjectId(int mSubjectId) {
    this.mSubjectId = mSubjectId;
}

public int getmActionId() {
    return mActionId;
}

public Map<String, String> getmClickableStringsList() {
    return mClickableStringsList;
}


public JSONArray getmFeedFilterArray() {
    return mFeedFilterArray;
}


public JSONObject getmFeedPostMenus() {
    return mFeedPostMenus;
}


public ArrayList<PhotoListDetails> getmPhotoDetails() {
    return mPhotoDetails;
}

public void setmPhotoDetails(ArrayList<PhotoListDetails> mPhotoDetails) {
    this.mPhotoDetails = mPhotoDetails;
}

public String getmActionTypeBody() {
    return mActionTypeBody;
}

public void setmActionTypeBody(String mActionTypeBody) {
    this.mActionTypeBody = mActionTypeBody;
}

public JSONObject getmFeedObject() {
    return mFeedObject;
}

public void setmFeedObject(JSONObject mFeedObject) {
    this.mFeedObject = mFeedObject;
}

public Map<Integer, String> getmVideoInfo() {
    return mVideoInfo;


}

public String getmWebUrl() {
    return mWebUrl;
}

public String getmFeedType() {
    return mFeedType;
}

public String getmFeedAttachmentType() {
    return mFeedAttachmentType;
}

}

How can I resolve this, anyone have any idea about this.

Thanks a lot in advanced !!!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
128 views
Welcome To Ask or Share your Answers For Others

1 Answer

Make your FeedList class Parcelable.

Use Parcelabler tool to create Parcelable class.

then Put intent like this -

intent.putExtra("feedList", mSelectedFeedList);

receive like this-

Bundle data = getIntent().getExtras();
Feedlist feedlist= (FeedList) data.getParcelable("feedList");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...