So I encountered an issue when passing object using Parcelable to another activity
My Model :
public class PostModel implements Parcelable {
@SerializedName("consumer")
public ConsumerModel consumer;
@SerializedName("attachments")
public List<AttachmentModel> attachments;
@SerializedName("polling_options")
public List<PollingModel> pollingOptions;
@SerializedName("total_like")
public String totalLike;
@SerializedName("total_polling")
public String totalPolling;
@SerializedName("question_like")
public QuestionLikeModel questionLikeModel;
}
I pass the parcelable object to another activity by using :
Bundle data = new Bundle();
data.putParcelable(Constants.DEFAULT_PARAM, postModel);
And retrieve by :
getIntent().getParcelableExtra(Constants.DEFAULT_PARAM);
But strangely enough, only my model QuestionLikeModel
returns null, the others are fine
So, I had to do this :
data.putParcelable(Constants.DEFAULT_PARAM, postmodel);
data.putParcelable("question_like", postModel.getQuestionLikeModel());
and set My model again by using this :
QuestionLike model q = getIntent().getParcelableExtra("question_like");
postModel.setQuestionLike(q);
To make it work
Has anyone encountered something like this before?