Dawid Hyży Dawid Hyży - 7 months ago 47
Android Question

How to send RealmObject in Bundle?

How to pass RealmObject through the Intents Bundle? Is there an way to write RealmObject to parcel?
I don't want to use Serializable for know reasons.


The easiest solution is to use Parceler: https://realm.io/docs/java/latest/#parceler

For example:

// All classes that extend RealmObject will have a matching RealmProxy class created
// by the annotation processor. Parceler must be made aware of this class. Note that
// the class is not available until the project has been compiled at least once.
@Parcel(implementations = { PersonRealmProxy.class },
        value = Parcel.Serialization.BEAN,
        analyze = { Person.class })
public class Person extends RealmObject {
    // ...