문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top