Like Activity (and other components), all services must be declared in the application's configuration file.
To declare a service, you must add a <service> sub-element to the <Application> element. For example:
<Manifest...>
...
<Application...>
<Service android: Name = ". exampleservice"/>
...
</Application>
</Manifest>
The <service> element also contains some other attribute definitions, such as the license required to start the service and the process in which the service should run. The Android: Name attribute is a unique and mandatory attribute. It specifies the Class Name of the service. Once you publish an application, you should not change this name, because if you modify it, it will interrupt the functions that use intent to reference this service.
For more information about declaring a service in the configuration file, see <service> element description.
Like activity, a service can also define an intent filter, allowing other components to use an implicit intent to call this service. By declaring the intent filter, any application component installed on the user's device can start your service (If your service declares that one or more applications are passed to startservice () method intent match intent filter ).
If you plan to use your service only locally (other applications do not use it), you do not need to provide any intent filter (and should not provide it ). Without any intent filter, you must use an exact intent named service class to start this service. More information about starting a service will be discussed in the "Start a service" section.
In addition, if you include the Android: exported attribute in the <service> element and set the attribute value to "false", you can ensure that the service is a private service of your application. Even if the Service supports the intent filter, this is also valid.