0

I am encountering the following issue:

Let's say I have a RiceContainerClass like so:

public class RiceContainerClass implements Serializable{
 private typeOfRice
 private countryOfOrigin

 ...

I am able extend this class, (maybe I want some SteamedRiceClass), but most importantly I am able to pass this class between Activities with my current implementation.

The issue arose when I decided that my Rice class might need to come with a Sauceable Interface.

I wrote the interface:

public interface Sauceable{

  public void setTypeOfSauce(Sauce sc)

  public Sauce getRiceSauce()
}

(In my program the Sauce is actually a Drawable)

When I modified my RiceContainerClass to implement the Sauce Interface:

public class RiceContainerClass implements Serializable, Sauceable

I get the following error during runtime from the logcat:

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.example.app.RiceContainerClass)

Any advice on what to do? I tried making the Sauce class extend Serializable, thought maybe that would work to no avail.

4

1 回答 1

0

这意味着app.RiceContainerClass不是Serializable

只要确保这个类实现了Serializable接口并定义了写入和读取对象的方法。

您可以在此处查看一些示例。

于 2013-06-19T22:05:15.710 回答