开发者

Error when starting an activity

开发者 https://www.devze.com 2022-12-24 04:36 出处:网络
开发者_如何学JAVAI\'m starting an activity when a button is pressed, and normally (in other apps) haven\'t had an issue.But when I press the button in this app, I get an \"unable to marshal value\" er
开发者_如何学JAVA

I'm starting an activity when a button is pressed, and normally (in other apps) haven't had an issue. But when I press the button in this app, I get an "unable to marshal value" error.

Exact(ish) error from LogCat:

03-22 02:49:02.883: WARN/System.err(252): java.lang.RuntimeException: Parcel: unable to marshal value {CLASSNAME}@44dcf1b8

I feel that this might be related to the extra that I'm passing to the intent. I'm passing an ArrayList as a serializable to this new intent. My concern is that the data structure that the ArrayList contains isn't being serialized (as it's a personal data structure).

Is the array list content data structure causing this? Something else that I'm missing?


Make sure your class implements Serializable too. Just because the ArrayList itself can be serialized, doesn't mean that serialization will work if your class is not serializable. This error is the exact one you will receive if you try to serialize an ArrayList of a class which does not implement Serializable.


Try passing a Parcelable instead of a Serializable object, that will solve the problem.


Make sure that the class you are using implements Serializable:

If you doing something like this:

Cars cars;
bundle.putSerializable("mySerializable", (java.io.Serializable) cars);

Make sure that the Cars class implement serializable:

public class Cars implements Serializable{
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号