Why does the background service stops while running?

前端 未结 4 1381
别跟我提以往
别跟我提以往 2021-01-23 08:10

I have a background service in my android application.In which a thread listening recent tasks running frequently.My service overrides both onCreate() and onS

4条回答
  •  佛祖请我去吃肉
    2021-01-23 08:29

    You have this code in your Service.onStartCommand():

    if(intent != null){
    

    You do realize that if Android kills the process hosting your Service, it will create a new process and create a new instance of your Service and restart it, calling onCreate() and then calling onStartCommand() with a null Intent. This is probably what is happening and why you think that onStartCommand() is not being called.

提交回复
热议问题