배경음을 service로 돌리고 있습니다.

그런데 도중에 전화가 오면 음악이 계속 울리네요..

아래는 서비스 액티비티입니다.

public class Music_Mystery extends Service {
 
 public MediaPlayer mp;

 @Override
 public IBinder onBind(Intent arg0) {
  // TODO Auto-generated method stub
  return null;
 }

 @Override
 public void onStart(Intent intent, int startId) {
  super.onStart(intent, startId);
  mp = MediaPlayer.create(this, R.raw.mystery);
  mp.setLooping(true);
  mp.start();
 }

 @Override
 public void onDestroy() {
  super.onDestroy();
  mp.stop();
 }
}

여기서 전화오면 중지시키는 방법이 있나요?

도와주세요!!

profile