Jeff Verdegan wrote:A couple of things do stand out though:
1. Not related to your problem, but as a matter of good design, your fields should be private, not public.
2. Not related to your problem, but as a matter of style, you should declare only one variable per line.
3. I don't see CREATOR fields in your classes. Parcelable's javadocs say: "Classes implementing the Parcelable interface must also have a static field called CREATOR, which is an object implementing the Parcelable.Creator interface."
Aleksey Vladimirovich wrote:
Jeff Verdegan wrote:A couple of things do stand out though:
1. Not related to your problem, but as a matter of good design, your fields should be private, not public.
2. Not related to your problem, but as a matter of style, you should declare only one variable per line.
3. I don't see CREATOR fields in your classes. Parcelable's javadocs say: "Classes implementing the Parcelable interface must also have a static field called CREATOR, which is an object implementing the Parcelable.Creator interface."
1, 2 Yeah, I know about it and it is so in real project, here I simplified code to type it faster.
3 Added CREATOR and necessary constructors.
The thing is, that classes which inherit my base class (class A) work perfectly unless they override implementation of Parcelable interface...
Jeff Verdegan wrote:Again, "doesn't work" doesn't tell us anything.
Jeff Verdegan wrote:This looks Android-specific, rather than Beginning Java, so I'll move it.
Aleksey Vladimirovich wrote:
Jeff Verdegan wrote:Again, "doesn't work" doesn't tell us anything.
Man, I don't how can I put this another way.
once a subclass overrides implementation of Parcelable interface (like class B) it's inherited fields don't serialize at all [MOD: empahsis mine] (I tried to achieve that by calling super.writeToParcel() and super.readFromParcel()).
Any ideas?
Aleksey Vladimirovich wrote:
Jeff Verdegan wrote:This looks Android-specific, rather than Beginning Java, so I'll move it.
Okay, but I wouldn't say it's very androidish problem, besides android thread is dead here...I asked a question once - no replies at all, and I wasn't the only.
Jeff Verdegan wrote:If you don't get any more answers in the next day or so, you can create a thread in Java in General with a link to this one, explaining that you did so because you weren't getting any responses here.
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|