1 00:00:00,490 --> 00:00:03,120 Everything we've done thus far in our course has been in the context 2 00:00:03,120 --> 00:00:04,600 of a single activity. 3 00:00:04,600 --> 00:00:06,760 This is fine for a lot of apps, but sooner or later, 4 00:00:06,760 --> 00:00:09,030 we're going to want to add more than one screen. 5 00:00:09,030 --> 00:00:11,440 Well, really soon, now, to be exact. 6 00:00:12,740 --> 00:00:16,930 Currently our app has one activity and one layout file associated with it. 7 00:00:16,930 --> 00:00:20,245 Let's add another one, and we'll see how to get to it from our main activity. 8 00:00:20,245 --> 00:00:23,680 We want to make sure that we add the new activity in the same package 9 00:00:23,680 --> 00:00:24,832 as our main activity. 10 00:00:24,832 --> 00:00:29,864 So right=click on the package here, then select New and then down here we 11 00:00:29,864 --> 00:00:35,314 can select Activity, and from the right we want this to be a new Empty Activity. 12 00:00:35,314 --> 00:00:36,370 For the name, 13 00:00:36,370 --> 00:00:42,091 let's call this StoryActivity because this will display the actual story. 14 00:00:42,091 --> 00:00:44,670 If we leave this checked, we'll get a new Layout File. 15 00:00:44,670 --> 00:00:46,410 We do not want this to be the Launcher Activity. 16 00:00:46,410 --> 00:00:48,350 Our main activity is the Launcher Activity, 17 00:00:48,350 --> 00:00:51,580 meaning that it's what's launched when the app first loads. 18 00:00:51,580 --> 00:00:55,429 We do want Backwards Compatibility checked so we can use the AppCompat activity, 19 00:00:55,429 --> 00:00:59,183 and we've already selected the correct package here, so we can click Finish. 20 00:01:01,563 --> 00:01:02,440 All right, easy enough. 21 00:01:02,440 --> 00:01:03,860 We'll set the layout in a little while. 22 00:01:03,860 --> 00:01:07,560 But first things first, let's figure out how to navigate here from our main 23 00:01:07,560 --> 00:01:10,050 activity when we tap on that button. 24 00:01:10,050 --> 00:01:11,910 So let's go back to our MainActivity file. 25 00:01:13,030 --> 00:01:14,940 And right now we are just toasting the name. 26 00:01:14,940 --> 00:01:17,460 We can go ahead and delete this line. 27 00:01:18,660 --> 00:01:21,250 But we do want to keep the code that sets the name variable as we're going 28 00:01:21,250 --> 00:01:22,320 to want that. 29 00:01:22,320 --> 00:01:24,520 Now we could just start our new activity right here, but 30 00:01:24,520 --> 00:01:26,510 instead let's put it inside of a new method. 31 00:01:26,510 --> 00:01:29,080 This will make things a little bit easier to understand. 32 00:01:29,080 --> 00:01:35,710 Let's just type a method and we'll create it with a quick fix, startStory() and 33 00:01:35,710 --> 00:01:40,590 now if we click on it and hit Alt+Enter, we can create the new method. 34 00:01:40,590 --> 00:01:42,320 And we want to create it inside MainActivity, 35 00:01:42,320 --> 00:01:44,830 not inside our anonymous inner class. 36 00:01:44,830 --> 00:01:47,560 That creates it down here as a private void method. 37 00:01:47,560 --> 00:01:52,470 And inside here, we want to start our new activity using an important Android object 38 00:01:52,470 --> 00:01:54,330 known as an intent. 39 00:01:54,330 --> 00:01:56,730 Let's talk about intents for a minute before we write the code we need.