Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build an Interactive Story App Intents and Multiple Activities Getting Text from an EditText

Why 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
Brad Wagner
9,379 Points

For 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.