Question

I usually use the interface Parcelable to pass data from one Activity to another. It is working fine if the data isn't that much. However, there are cases where I have to pass a lot of data to an Activity. Marshalling of these data seems to happen without any error but unmarshalling results in an Error like this:

07-23 14:26:34.215: E/AndroidRuntime(29379): java.lang.OutOfMemoryError: java.lang.Object[] of length 1075971147 exceeds the VM limit

It seems that it is just too much data to get unmarshalled. A really Hackish solution (that I really don't like) will be to give that special Activity a static Method to pass that data to it, looking for it at onCreate(). This would work at least for Activitys I have control over the source, but fails if I haven't.

I wanna know if there are other acceptable attemts, to pass a bunch of data from one Activity to another. It would be really nice if I could reuse some code I already wrote for the Parcelable interface, but that is not an requirement

Was it helpful?

Solution

How about creating a global variable (like described here)? There was a time I was struggling with the same problem and in the end it was all I found working (even though I cannot say "global" appears like a "good practice").

OTHER TIPS

How about using a Bus architecture (EventBus/Otto), then you can transfer any POJO between any Android components.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top