Skip to content Skip to sidebar Skip to footer

Stop Intentservice From Activity

I need help with this situation: I have activity, what starts IntentService. Service do some job in while cycle and sleep for some time. Main cycle of service is endless, so I nee

Solution 1:

Service do some job in while cycle and sleep for some time.

IMHO, this is an inappropriate use of IntentService. Please create a regular Service, with your own background thread that you manage yourself.

Is there any solution how to do this?

Create a regular Service, with your own background thread that you manage yourself. For example, you could use a ScheduledExecutorService instead of your sleep() loop, using shutdown() or shutdownNow() in the service's onDestroy().

Post a Comment for "Stop Intentservice From Activity"