Search code examples
androidandroid-activitypojo

How to pass not basic data to activity on creation?


In every example I saw, the data is somehow synonymous to basic (raw) data -- ints, chars, array of bools, and so on -- this is too limiting for me, because I would like to pass a regular object.

So how to pass any data to activity, like for example, instance of MyClass?

I checked the Intent.putExtra -- all I found was basic types + Bundle, but Bundle itself also handles only basic types.


Solution

  • There are several way to do it as described in android guide faq.

    I think that in your case static variables could help most.

    You could also implement Application and use it to share your data between Activities. Here is short tutorial on that.