2

It seems that if I don't generate the getters and setters for my RealmObject and send it to another activity using Parceler, all the attributes are reset to their default value.

Is there a way to avoid creating these getters and setters and keep the values?

Thanks.

seb
  • 312
  • 1
  • 4
  • 13
  • If it's a managed realmObject then consider requerying it in the other activity based on its primary key – EpicPandaForce Apr 30 '17 at 16:58
  • Unfortunately, It's an unmanaged object because I also want to use two-way data binding. I think what I'm trying to do is poorly designed and I need to refactor. – seb Apr 30 '17 at 18:04
  • 1
    I see, make sure you DON'T specify Serialization.BEAN, but you also probably don't need analyze either – EpicPandaForce Apr 30 '17 at 18:23
  • Removing Serialization.BEAN and analyze did the trick. I can now use Parceler without getter/setter and I still have the value I have set. I will spend more time on the documentation to really understand what that change means. Thanks for your time. – seb Apr 30 '17 at 18:44
  • 1
    It means it won't try to use getters/setters for serialization (BEAN) but it won't consider its implementation (analyze), I made the assumption that you don't try to parcel managed objects. – EpicPandaForce Apr 30 '17 at 19:15
  • Once again thank you for your explanation. It's my first question on SO, should I 'close' the question somehow? – seb Apr 30 '17 at 19:30
  • I posted it as an answer, this way you can accept it with the tick thing on the side :D – EpicPandaForce Apr 30 '17 at 19:41

1 Answers1

1

Make sure you DON'T specify Serialization.BEAN, but you also probably don't need analyze either.

It means it won't try to use getters/setters for serialization (BEAN) but it won't consider its implementation (analyze), I made the assumption that you don't try to parcel managed objects.

EpicPandaForce
  • 79,669
  • 27
  • 256
  • 428