so I am getting this in logcat:
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.resources.student_list
Need to change all arraylist to Serializable wif in bean class :
public static class PremiumListBean implements Serializable {
private List<AddOnValueBean> AddOnValue;
public List<AddOnValueBean> getAddOnValue() {
return AddOnValue;
}
public void setAddOnValue(List<AddOnValueBean> AddOnValue) {
this.AddOnValue = AddOnValue;
}
public static class AddOnValueBean implements Serializable{
@SerializedName("Premium")
private String Premium;
public String getPremium() {
return Premium;
}
public void setPremium(String Premium) {
this.Premium = Premium;
}
}
}
The problem occurs when your custom class has for property some other class e.g. "Bitmap". What I made is to change the property field from "private Bitmap photo" to "private transient Bitmap photo". However the image is empty after I getIntent() in the receiver activity. Because of this I passed the custom class to the intent and also I've created a byte array from the image and pass it separatly to the intent:
selectedItem is my custom object and getPlacePhoto is his method to get image. I've already set it before and now I just get it first than convert it and pass it separatly:
Bitmap image = selectedItem.getPlacePhoto();
image.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Intent intent = new Intent(YourPresentActivity.this,
TheReceiverActivity.class);
intent.putExtra("selectedItem", selectedItem);
intent.putExtra("image", byteArray);
startActivity(intent);
`
Then in the receiver activity I get my object and the image as byte array, decode the image and set it to my object as photo property.
Intent intent = getIntent();
selectedItem = (ListItem) intent.getSerializableExtra("selectedItem");
byte[] byteArray = getIntent().getByteArrayExtra("image");
Bitmap image = BitmapFactory.decodeByteArray(byteArray, 0,
byteArray.length);
selectedItem.setPhoto(image);
Your OneThread Class also should implement Serializable. All the sub classes and inner sub classes must implements Serializable.
this is worked for me...
the Grade class must also implement Serializable
public class Grade implements Serializable {
.....your content....
}
Caused by: java.io.NotSerializableException: com.resources.student_list.DSLL$DNode
Your DSLL
class appears to have a DNode
static inner class, and DNode
is not Serializable
.
If you can't make DNode serializable a good solution would be to add "transient" to the variable.
Example:
public static transient DNode dNode = null;
This will ignore the variable when using Intent.putExtra(...).