66.9 Launching the Service
Edit the MainActivity.kt file and modify the buttonClick() method to launch the MyService service:
package com.ebookfrenzy.serviceexample
.
.
import android.content.Intent
class MainActivity : AppCompatActivity() {
.
.
fun buttonClick(view: View)
{
intent = Intent(this, MyService::class.java)
startService(intent)
}
}
All that the buttonClick() method does is create an intent object for the new service and then start it running.