Friends, please tell me, this task works IntentService when it performs a task it starts another service from which I need to kill the old service - how to do it? I use it:

 stopService(new Intent(service_scan.this, gate_service.class)); 
  • And he doesn't type like that? ... - YuriySPb
  • No, it works as if nothing had happened and the Activity hangs up, which starts this service. - John Stacker
  • And how do you understand that the service does not die? You output to the logs in the method of death of the service something, but this method is not called? Maybe you just then start the usual service that slows down the activation, and IntentService safely died? Little info. - Yuriy SPb
  • My logs are: D / STATUS: gate_sevice D / STATUS: Activity dialog D / STATUS: gate_sevice D / STATUS: gate_sevice loop D / STATUS: loop time set to 24 D / STATUS: gate_sevice D / STATUS: gate_sevice D / STATUS: service_scan D / STATUS: gate_sevice loop D / STATUS: loop time set to 19 D / STATUS: gate_sevice D / STATUS: gate_sevice - John Stacker
  • After Activity dialog there shouldn’t be anything to go but it goes - John Stacker

1 answer 1

IntentService should stop itself if there are no tasks:

Asynchronous requests (express as Intents) on demand. Clients send requests through startService (Intent) calls; it is not necessary to use the service line when it runs out of work.

The connection between the activity and the service, how they are connected, is not very clear. Alternatively, use BoundService - as soon as you unbind it, the system will stop it.

unbindService (ServiceConnection conn)

Added in API level 1 Disconnect from an application service. You can no longer receive calls at any time.