Вопрос

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