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
ronw
7,894 PointsFun Facts app reverts to first screen when the device orientation changes.
I'm going through the "Build a Simple Android App" course. I have finished building the 'Fun Facts' app. I am debugging the app on my tablet.
Whenever I change the orientation of the tablet (from portrait to landscape or vice versa) the app reverts to the first screen (the first fun fact).
UPDATE: I realize the onCreate() method of the FunFactsActivity class is getting called each time the device orientation changes.
What causes this?
Coinnich c
7,512 PointsCoinnich c
7,512 PointsHello Ron,
I believe this is because of the Android systems lifecycle. When an orientation is changed the app will have to rebuild itself. Typically applications will be designed to handle this change, but in this course the Fun Facts app wasn't designed to. In fact if memory serves we went to the manifest and made our application only support the portrait orientation. I haven't yet finished the Android track, so am unsure if there are any courses which discuss this. However this link
Activity lifecycle on Orientation Change
Helps explain it.
Hope this helps.