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
Michael McKenna
3,451 PointsHow do I see which activity a fragment is a part of?
I am viewing somebody's code and I see that they can just call getActivity(). How can I figure out which activity the fragment is a part of?
1 Answer
EVGENII MAMONTOV
7,666 PointsWell, getActivity() method gives you the parent activity of the fragment. Then you can use, for example, .class.getSimpleName() to get that activity's name. Is this what you need?
Michael McKenna
3,451 PointsMichael McKenna
3,451 PointsThat's exactly it. Thank you