0 1 00:00:08,280 --> 00:00:14,340 So far we've seen an activity a content provider and a broadcast receiver. 1 2 00:00:14,340 --> 00:00:20,690 Now we're going to look at a service so here you're probably familiar with services from other operating 2 3 00:00:20,690 --> 00:00:28,630 systems. The concept is similar here you usually use a service when you want to do a long task in the 3 4 00:00:28,630 --> 00:00:34,620 background or you want to expose features of your app in the background. 4 5 00:00:34,760 --> 00:00:41,460 We won't go into too much detail here but we will show a basic service and how to define it. So let's 5 6 00:00:41,460 --> 00:00:53,890 add a class called my service default settings extend service alt and enter to implement methods and 6 7 00:00:53,890 --> 00:00:57,460 here you can see it created the unbind method. 7 8 00:01:00,350 --> 00:01:08,130 So just as the other components we need to add this service to the components in the manifest, so service 8 9 00:01:09,500 --> 00:01:23,980 Android colon name equals my service let's give it an icon Android colon icon equals drawable I see 9 10 00:01:24,250 --> 00:01:35,460 launcher background and a label Android colon label equals string app name OK. 10 11 00:01:35,470 --> 00:01:38,200 So we just defined a service. 11 12 00:01:38,220 --> 00:01:46,680 Now if you remember we had the lifecycle of an activity, a service has a different lifecycle actually. 12 13 00:01:46,700 --> 00:01:53,060 There are two options depending on how they were launched so here for example you have when it started 13 14 00:01:53,120 --> 00:02:02,860 with the start command and here with on bind then there is the service running. The unbind 14 15 00:02:02,860 --> 00:02:11,620 in the case of bind and I'm destroying over here for both so just like that we have our service defined 15 16 00:02:11,650 --> 00:02:14,770 in our app but it doesn't do anything yet.