问题描述:

I moved the Model to an external Dependency so I can reuse it on Server and other Parts. But now I'm having the Problem that when I serialize to Intents Extra and then deserialize in BroadcastReceiver the deserialized Object is not null but it's Properties have the default Values like null (for the Strings) or 0 (for int or long).

This is excerpt from the Models Class:

public class Measurement extends Event implements Serializable {

private static final long serialVersionUID = 8246754793603601250L;

/* Some other Stuff */

}

And this from Serialization:

List<Measurement> measurements = new ArrayList<Measurement>();

/* measurements get filled */

extras.putSerializable(Intents.EXTRA_MEASUREMENTS, (Serializable) measurements);

And this from Deserialization:

List<Measurement> measurements = (List<Measurement>) intent.getSerializableExtra(Intents.EXTRA_MEASUREMENTS);

网友答案:

All members of Measurement and members of its members (recursion) would be Serializable

网友答案:

Found it. Problem was that the underlying Class Event didn't implement Serializable. Looks like this got lost during Refactoring and moving to an external Dependency.

Thanks to everybody.

相关阅读:
Top