package com.xd.notifydemokotlin

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {
    private lateinit var startButton: Button
    private lateinit var stopButton: Button

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        startButton = findViewById(R.id.startservice)
        stopButton = findViewById(R.id.stopservice)

        startButton.setOnClickListener(){
            val intent = Intent(this, NotifyService::class.java)
            startService(intent)
        }

        stopButton.setOnClickListener(){
            val intent = Intent()
            intent.action = NotifyService.STOP_SERVICE_ACTION
            sendBroadcast(intent)
        }
    }
}