아직 서비스에 대한 개념도 덜 잡혔지만.. 일단 어떻게든 사용하고 있습니다.


메인액티비티에서 서비스를 호출하고 있습니다.

startService(new Intent(this, testService.class)); 



그리고 메인액티비티에서 아래처럼 서비스를 중단하고 있습니다.

stopService(new Intent(this, testService.class)); 


그리고 서비스내에서 뷰로 이미지를 뛰우고, 이미지를 터치하면 특정 작업을 수행합니다.


여기서 하려는 특정작업이 서비스를 멈추는것인데요...


어떻게 해야할지 모르겠습니다. ㅠ  operation 부분에서 서비스를 멈추는법 알려주세요! 


아래는 소스코드입니다. 조언 부탁드려요! 

 

 

public class testService extends Service{

@Override

public void onCreate() {

super.onCreate();

imgViewX = new ImageView(this);

imgViewX.setImageResource(R.drawable.icon_x);

imgViewX.setOnTouchListener(new OnTouchListener(){

@Override

public boolean onTouch(View v, MotionEvent event) {

switch(event.getAction()) {

case MotionEvent.ACTION_DOWN:

Log.e(LOG_TAG,"Touch Down!");

//operation

break;

}

}

});

}//onCreate

};