Question

I have an app that keeps users login control. When user does login I want to start a service that keeps running until the user makes logout. So I start a service that returns (return START_STICKY;) on its onStartCommand method.

But I cannot stop it after the user does logout. Is there any way to do this?

I've tried doing it through broadcast intent but it doesn't stop always as I guessed.

Thanks in advance

Was it helpful?

Solution

Option #1: Get rid of the service entirely. You have not stated what the service is doing, and it is possible that you do not need the service in the first place.

Option #2: Call stopService() to stop the service.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top