1 00:00:00,220 --> 00:00:06,180 We've learned the ton about threads, but now it's time we see why services exist. 2 00:00:06,180 --> 00:00:08,600 Let's start by opening the Android device monitor. 3 00:00:13,301 --> 00:00:14,290 And then running our app. 4 00:00:23,470 --> 00:00:26,370 Then let's find our app in the list on the left 5 00:00:30,430 --> 00:00:34,660 click it, and then click up here to show our app's threads 6 00:00:40,399 --> 00:00:45,159 Notice that this time our downloadThread already exists because we now create 7 00:00:45,159 --> 00:00:50,230 it in the on create method instead of when we click the download button. 8 00:00:50,230 --> 00:00:56,080 Now let's click the download button and watch our song start to download. 9 00:01:02,490 --> 00:01:07,721 After ten seconds we can see them start downloading in the log messages below. 10 00:01:11,440 --> 00:01:13,580 And another ten we get another song. 11 00:01:15,720 --> 00:01:21,590 But now with our app still selected let's click this stop sign up here 12 00:01:21,590 --> 00:01:22,760 to kill our process. 13 00:01:24,000 --> 00:01:28,570 Immediately we can see that the app is no longer running and 14 00:01:28,570 --> 00:01:33,180 if we give it a few seconds we can tell that our download thread has stopped too. 15 00:01:34,430 --> 00:01:35,610 No more log messages. 16 00:01:37,000 --> 00:01:41,180 Now I know what you're thinking, this isn't that surprising. 17 00:01:41,180 --> 00:01:43,670 You killed the app, but of course everything stopped. 18 00:01:44,780 --> 00:01:49,775 But it didn't have to be that way since processes are routinely kiln 19 00:01:49,775 --> 00:01:55,095 to free up resources, Android provides us with a way of dealing with this and 20 00:01:55,095 --> 00:01:57,085 that way is services.