So far we've seen an activity a content provider and a broadcast receiver. 1
Now we're going to look at a service so here you're probably familiar with services from other operating 2
systems. The concept is similar here you usually use a service when you want to do a long task in the 3
background or you want to expose features of your app in the background. 4
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
add a class called my service default settings extend service alt and enter to implement methods and 6
here you can see it created the unbind method. 7
So just as the other components we need to add this service to the components in the manifest, so service 8
Android colon name equals my service let's give it an icon Android colon icon equals drawable I see 9
launcher background and a label Android colon label equals string app name OK. 10
So we just defined a service. 11
Now if you remember we had the lifecycle of an activity, a service has a different lifecycle actually. 12
There are two options depending on how they were launched so here for example you have when it started 13
with the start command and here with on bind then there is the service running. The unbind 14
in the case of bind and I'm destroying over here for both so just like that we have our service defined 15
in our app but it doesn't do anything yet.