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 trialFarhan Zafar
Courses Plus Student 1,466 PointsWhy we're still using MainActivity.java? although we have created another similar java file? used for portrait mode?
I watched the previous video in which we created another java file which forces the app to only stay in portrait mode on rotation, but I don't understand why we're writing our rest of the code in MainActivity.java why not write it in the portrait java file? the instructor said those both the files are doing the same work!
Thanks for your time.
1 Answer
Brad Wagner
9,392 PointsFor now, I'm only thinking of the InteractiveStoryApplication class's single purpose is to set the portrait mode as in setting the stage for all the Activities that we make henceforth. It is instantiated before any other class when the process for your application/package is created so it comes before any Activity class. Any Activity that we make from now on will be in portrait instead of having to set '<activity android:name=".MainActivity"> in each of their corresponding .xml manifest files. We can only do that with an Application class and not an Activity class (apply the portrait mode to affect all Activities in our package). We don't want to put all of our code in InteractiveStoryApplication so we can divvy up other functionality to other classes.