destroy an android service

Posted by Jack Trowbridge on Stack Overflow See other posts from Stack Overflow or by Jack Trowbridge
Published on 2012-06-29T08:52:20Z Indexed on 2012/06/29 9:16 UTC
Read the original article Hit count: 295

Filed under:
|
|

I am using a service in my android app, which is called when an alarm is activated by a calander. When the service has been activated i want it to be destroyed by the OnStart() method once it has completed its code.

My OnStart() method:

@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);

Vibrator vi = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

vi.vibrate(5000);

Toast.makeText(this, "MyAlarmService.onStart()", Toast.LENGTH_LONG).show();

    //CODE HERE TO DESTROY SERVICE??

}

This bassically means when the service is called it runs the code in the OnStart() method and i want it to destroy itself. Any Ideas, methods that would do this?.

Thanks, jack.

© Stack Overflow or respective owner

Related posts about android

Related posts about service