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
Zuhayr Elahi
2,582 PointsPass objects between activities
So I have been working on my own app to practice what I have been learning from these courses and I am stuck at one area. Here are the details, if needed I can also post the code:
So I have information on one screen which I am saving to an object. I am then passing that object to another activity. To do this I had the original class implement Parcelable. The issue I am having is that when I start the next activity I am getting a null pointer exception saying the instance of that object wasn't created.
Has anyone encountered something similar? If I am not clear I can post my errors and codes to repo as well
2 Answers
Steve Hunter
57,712 PointsHi there,
Using Parcelables is a good way of passing information between activities, yes.
Posting your code that handles both ends of the Parcel will help and if you have your project in a repo, that may assist too.
Steve.
Zuhayr Elahi
2,582 PointsThanks. So I took an alternative approach actually. So instead of having something as an object, what I did was convert what I needed to a JSON object, and then passed that JSON object