Tuesday, April 24, 2018

Apparently arbitrary objects can't be put in Intents as extras

Today I wanted to call a different Android Activity and supply an instance of a new class to it. I looked at the methods on the Bundle returned by the new Intent's getExtras method, but found nothing that puts an arbitrary object. To my shock, there is no way to store just any object, apparently because Intents can cross process boundaries, so an object alive in one app can't just be brought over to another. You have to either serialize/parcel the object or stash it somewhere the other Activity can get it.

No comments:

Post a Comment