67.4 Starting the Service
Now that the service has been implemented and declared in the manifest file, the next step is to add code to start the service when the application launches. As is typically the case, the ideal location for such code is the onCreate() callback method of the activity class (which, in this case, can be found in the MainActivity.kt file). Locate and load this file into the editor and modify the onCreate() method to add the code to start the service:
package com.ebookfrenzy.serviceexample
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.content.Intent
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
...