In android development, I have service that started by Brodcastreceiver ,and it started and did its task properly , but when I try to stop the service from its class by using stopself(); it did not stop until performing its task three times and then its stop here is the code for the onStart service and onDestroy();:
@Override
public void onStart(Intent intent, int startid) {
player.start();
SystemClock.sleep(30000);
onDestroy();
}
@Override
public void onDestroy() {
player.stop();
this.stopSelf();}
and here is the code when I started the service from the BrodcastReceiver:
Intent intent =new Intent(context,RingService.class);
context.startService(intent);
Is there any way to make my service stop immediately once its finished its task by itself , or do I have to make the BrodcastRecevicer stop it?
any help or redirection to solve this issue will be completlly appreciated
regards