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
Ojong Obasi
6,561 PointsIn the blog reader app Android, how do I pass the value of the blog title and the value of the author to another activit
In the blog reader app Android, how do I pass the value of the blog title and the value of the author to another activity. I just want to display the blog title and author name in another activity without using webview. How can I achieve this? thanks
1 Answer
Dan Johnson
40,533 PointsFor simple objects like Strings an easy way to do it is to pass it in with the intent. For example with the title, you could pass it along like this:
//...
Intent intent = new Intent(this, YourOtherActivity.class);
intent.putExtra("blogTitleKey", blogTitle);
startActivity(intent);
//...
And then retrieve it using the same key in the new activity:
//...
Intent intent = getIntent();
String title = intent.getStringExtra("blogTitleKey");
//...
Hope that helps.