How To Send An Object To Another Activity With Special Stuff?
I am developing a math app for kids. After the user customizes the question options, I want to start another activity. I want to send a QuestionOptions object to the activity so th
Solution 1:
I've tried your code and it seems the problem is with the parcelable object. Please update the following and it will work:
The constructor that accepts a Parcel object.
protected QuestionOptions(Parcel in) {
this.operationType = OperationType.valueOf(in.readString());
this.digitCount = in.readInt();
this.timerEnabled = in.readByte() != 0;
}
and the writeToParcel method.
@OverridepublicvoidwriteToParcel(Parcel dest, int flags) {
dest.writeString(this.operationType.name());
dest.writeInt(this.digitCount);
dest.writeByte((byte) (this.timerEnabled ? 1 : 0));
}
You can get the object from the intent in the following way:
finalQuestionOptionsoptions= getIntent().getParcelableExtra("com.smartkidslovemaths.option");
Post a Comment for "How To Send An Object To Another Activity With Special Stuff?"