Android 如何使用intent传递自定义列表对象

Android 如何使用intent传递自定义列表对象,android,json,android-intent,arraylist,adapter,Android,Json,Android Intent,Arraylist,Adapter,我正在开发android应用程序,我想通过intent将Cutom列表对象传递给其他活动。 我创建了CustomList类来实现可序列化接口。 并使用以下代码通过intent发送数据: FeedList mSelectedFeedList = mFeedItemList.get(position); Intent intent = new Intent(mContext, SingleFeedPage.class);

我正在开发android应用程序,我想通过intent将Cutom列表对象传递给其他活动。 我创建了CustomList类来实现可序列化接口。 并使用以下代码通过intent发送数据:

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);
当我通过intent发送此mSelectedFeedList时,我收到以下错误:

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.socialengineaddons.mobileapp.classes.common.utils.FeedList)
下面是我的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;
}
公共类提要列表{
私有字符串mFeedIcon、mFeedTitle、mFeedPostTime、mWebUrl、mActionTypeBody、mFeedAttachmentType;
private int mAttachmentCount、mliketcount、mCommentCount、mIsLike、mPhotoAttachmentCount;
可共享的私有int;
私有int mCanComment;
专用JSONArray mFeedMenusArray、MFEEADTACHMENTARRAY、mFeedFilterArray;
私有JSONObject MFeedFooter菜单、mFeedPostMenus、mFeedObject;
字符串mHiddenBodyText、mUndoHiddenFeedURl、mHideAllText、mHideAllUrl、mHideAllName、mFeedType;
int-msubject,mActionId;
地图mClickableStringsList;
地图信息;
布尔无馈送;
阵列列表mPhotoDetails;
公共提要列表(int actionId、int subjectId、字符串mFeedTitle、字符串mFeedIcon、JSONArray
mFeedMenusArray、字符串mFeedPostTime、int attachmentCount、int likeCount、int commentCount、,
int CANCOMENT、int isLike、JSONObject feedObject、JSONArray feedAttachmentArray、int photoAttachmentCount、,
JSONObject FeedFooter菜单、int可注释、int可共享、,
Map ClickableString、String actionTypeBody、Map videoInfo、,
字符串url、字符串feedAttachmentType、字符串类型){
this.mSubjectId=主语;
this.mFeedTitle=mFeedTitle;
this.mFeedIcon=mFeedIcon;
this.mFeedMenusArray=mFeedMenusArray;
this.mFeedPostTime=mFeedPostTime;
mAttachmentCount=附件计数;
mLikeCount=likeCount;
mCommentCount=commentCount;
mIsLike=isLike;
mCanComment=癌症;
this.mFeedObject=feedObject;
this.mFeedAttachmentArray=feedAttachmentArray;
this.mPhotoAttachmentCount=photoAttachmentCount;
this.mcommantable=可评论;
this.msharable=可共享;
mFeedFooterMenus=feedFooterMenus;
mActionId=actionId;
mClickableStringsList=可点击字符串;
mVideoInfo=视频信息;
mWebUrl=url;
mActionTypeBody=actionTypeBody;
mFeedAttachmentType=feedAttachmentType;
mFeedType=类型;
}
公共FeedList(JSONObject feedPostMenus、JSONArray FeedFilterArray、布尔isNoFeed){
mfeedpostemnus=feedpostemnus;
mFeedFilterArray=馈线滤波器阵列;
this.noFeed=isNoFeed;
}
公共布尔值isNoFeed(){
返回noFeed;
}
公共字符串getmFeedIcon(){
返回mFeedIcon;
}
公共字符串getmFeedTitle(){
返回标题;
}
公共字符串getmFeedPostTime(){
返回mFeedPostTime;
}
publicjsonarray getmFeedMenusArray(){
返回mFeedMenusArray;
}
public void setmFeedMenuArray(JSONArray mFeedMenuArray){
this.mFeedMenusArray=mFeedMenusArray;
}
public int getmAttachmentCount(){
返回mAttachmentCount;
}
public int getmlikecont(){
返回mlikcount;
}
公共无效设置mLikeCount(整数mLikeCount){
this.mlikecont=mlikecont;
}
public int getmCommentCount(){
返回mCommentCount;
}
公共void setmCommentCount(int-mCommentCount){
this.mCommentCount=mCommentCount;
}
public int getmIsLike(){
返回错误;
}
公共无效集类(int类){
this.mIsLike=mIsLike;
}
公共int ismCanComment(){
返回mCanComment;
}
public int getmPhotoAttachmentCount()的值{
返回mPhotoAttachmentCount;
}
公共JSONArray getmFeedAttachmentArray(){
返回mFeedAttachmentArray;
}
公共JSONObject getmFeedFooterMenus(){
返回菜单;
}
公共无效setmFeedFooterMenus(JSONObject mFeedFooterMenus){
this.mFeedFooterMenus=mFeedFooterMenus;
}
公共字符串getmHiddenBodyText(){
返回mHiddenBodyText;
}
public void setmHiddenBodyText(字符串mHiddenBodyText){
this.mHiddenBodyText=mHiddenBodyText;
}
公共字符串getmUndoHiddenFeedURl(){
返回mundohidenfeedURL;
}
公共void setmUndoHiddenFeedURl(字符串mUndoHiddenFeedURl){
this.mUndoHiddenFeedURl=mUndoHiddenFeedURl;
}
公共字符串getmHideAllText(){
返回mHideAllText;
}
public void setmHideAllText(字符串mHideAllText){
this.mHideAllText=mHideAllText;
}
公共字符串getmHideAllUrl(){
返回mHIDEALLRL;
}
public void setmHideAllUrl(字符串mHideAllUrl){
this.mHideAllUrl=mHideAllUrl;
}
公共字符串getmHideAllName(){
返回mHideAllName;
}
public void setmHideAllName(字符串mHideAllName){
this.mHideAllName=mHideAllName;
}
public int getmCommentAble(){
返回mCommentAble;
}
公共void setmCommentAble(int mCommentAble){
this.mcommantable=mcommantable;
}
public int getmsharable(){
返回msharable;
}
公共void setmsharable(int-msharable){
this.mShareAble=mShareAble;
}
public int getmsubjected(){
返回msubjectd;
}
public void setmSubjectId(int mSubjectId){
this.mSubjectId=mSubjectId;
}
public int getmActionId(){
返回mActionId;
}
公共地图getmClickableStringsList(){
返回mClickableStringsList;
}
公共JSONArray getmFeedFilterArray(){
返回mFeedFilterArray;
}
公共JSONObject getmFeedPostMenus(){
返回mFeedPostMenus;
}
公共阵列列表getmPhotoDetails(){
返回mPhotoDetails;
}
public void setmPhotoDetails(ArrayList mPhotoDetails){
this.mPhotoDetails=mPhotoDetails;
}
公共字符串getmActionTypeBody(){
返回mActionTypeBody;
}
公共void setmActionTypeBody(字符串mActionTypeBody){
this.mActionTypeBody=mActionTypeBody;
}
公共JSONObject getmFeedObject(){
返回mfeed对象;
}
公共void setmFeedObject(JSONObject mFeedObject){
this.mFeedObject=mFeedObject;
}
公共地图GetMVideInfo(){
返回mvideinfo;
}
公共字符串getmWebUrl(){
返回mWebUrl;
}
公共字符串getmFeedType(){
返回mFeedType;
public class Student implements Parcelable{
        private String id;
        private String name;


        // Constructor
        public Student(String id, String name ){
            this.id = id;
            this.name = name;

       }
       // Getter and setter methods
       .........
       .........

       // Parcelling part
       public Student(Parcel in){
           String[] data = new String[3];

           in.readStringArray(data);
           this.id = data[0];
           this.name = data[1];

       }

       @Оverride
       public int describeContents(){
           return 0;
       }

       @Override
       public void writeToParcel(Parcel dest, int flags) {
           dest.writeStringArray(new String[] {this.id,
                                               this.name });
       }
       public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
           public Student createFromParcel(Parcel in) {
               return new Student(in); 
           }

           public Student[] newArray(int size) {
               return new Student[size];
           }
       };
   }
intent.putExtra("student", new Student("1","Mike"));
Bundle data = getIntent().getExtras();
Student student = (Student) data.getParcelable("student");
public class Student implements Serializable {
        private String id;
        private String name;



        public Student(String id, String name ){
            this.id = id;
            this.name = name;

       }
       public string getId() {
          id;
       }


       public string setName() {
         name;
       }

   }
Bundle bundle = new Bundle();
bundle.putSerializable("student", new Student("1","Mike"));
intent.putExtras(bundle);
Intent intent = this.getIntent();
Bundle bundle = intent.getExtras();

Student st=(Student )bundle.getSerializable("value");
intent.putExtra("feedList", mSelectedFeedList);
Bundle data = getIntent().getExtras();
Feedlist feedlist= (FeedList) data.getParcelable("feedList");