How pass complex object containing stream to activity

86 views Asked by At

I'm currently trying to pass an Object from the main activity to another. My object is Patient

public Patient(int id, String name,JsonReader jsr, JsonWriter jsw, String firstName, String birth,
        String vcf, String[] clinicalFactors) 

I need the JsonReader and writer on the other side. I saw that i have to make the patient parcelable but from what i understood the method writetoparcel support only some specific type. i tried to use the method writeValue but then at readFromParcel i don't know how to read the stream.

Hope it's sufficiently clear. Thank you in advance

1

There are 1 answers

0
Peri Hartman On BEST ANSWER

If you truly need to share objects among your app's activities, you can do it by subclassing Application. There is one instance of Application and it gets initialized before any activities start and sticks around for the life of all activities in your app.

If you can find another way to pass info, such as passing a file name or database primary key, that would be better.

Note that Application is only available to your activities. So, it won't help if you are trying to pass info to another app.