Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Waldo Alvarado
Waldo Alvarado
16,322 Points

How do you pass an array of classes through an intent to another activity?

I have a class called Names. I then created an array Names[] names = new Names[10]; holding 10 of those classes. Then I ran a for loop to assign a new Names() object to each of them.

Through the app the user inputs 10 names, each name gets saved to a variable inside of each Names class in the array. I now want to pass this names array to another activity through an intent but I have not been able to do so.

In other words, my question is: how do I pass an array of classes through an intent to another activity?

1 Answer

andren
andren
28,558 Points

Have you watched the Treehouse course "Using Parcelable Data"? If not then I would recommend going through it, the example they show is taking an array of objects and sending it trough an intent, which sound like the exact same thing you are trying to do.