Declaring your service

To declare your service, you need to add its class to the Android Manifest. The following code snippet explains what the service definition in Android Manifest should look like:

    <manifest xmlns:android=     ""         package="com.journaler"> 
      <application ... > 
          android:exported="false" /> 
      </application>      </manifest>

As you can see, we defined the MainService class that extends the Service class and it's located under the service package. The exported flag is set to false, which means that the service will run in the same process as our application. To run your  service in a separate process, set this flag to true.

It's important to ...

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.