How to stop service by itself?

前端 未结 11 1245
独厮守ぢ
独厮守ぢ 2020-12-02 14:10

I start a service in an activity then I want the service to stop itself after a while.

I called stopSelf() in the service but it doesn\'t work.

How to make t

11条回答
  •  半阙折子戏
    2020-12-02 15:01

    By calling stopSelf(), the service stops.

    Please make sure that no thread is running in the background which makes you feel that the service hasn't stopped.

    Add print statements within your thread.

    Hope this helps.

提交回复
热议问题