destroy an android service
- by Jack Trowbridge
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.