package com.example.ghomi.chapter6_3;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button play,stop;
        play = (Button)findViewById(R.id.btnPlay);
        play.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View view){
                Intent myIntent = new Intent(MainActivity.this, MyService.class);
                startService(myIntent);
            }
        });

        stop=(Button)findViewById(R.id.btnStop);
        stop.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View view){
                Intent myIntent = new Intent(MainActivity.this, MyService.class);
                stopService(myIntent);
            }
        });
    }
}
