Android Background Service is restarting when application is killed

前端 未结 7 2254
逝去的感伤
逝去的感伤 2020-11-27 17:20

I am developing an application in which a background service is created to collect sensor data. I am starting the service from my activity:

startService(new          


        
7条回答
  •  独厮守ぢ
    2020-11-27 17:27

    When the memory is low, a service running in background automatically gets killed. Instead of using startService() to start a service, try using StartForeground() instead. The service runs in the foreground and will never be killed even if memory is low.

提交回复
热议问题