Background service pause and start again automatically on OREO

前端 未结 1 1176
挽巷
挽巷 2020-12-07 04:56

I have created a background service for registering SCREEN_ON and SCREEN_OFF intent to catch an event using broadcast receiver but some time due to unknown reason my service

相关标签:
1条回答
  • 2020-12-07 05:47

    There is a restriction for service in Oreo onward, We can start a service by calling startService() only when the application is in foreground. When you exit from the app (app is in background), then it has a window of several minute, in that app can run the service. At the end of window, app considered to be idle,that time system stop the background service. In order to achieve run a service even in background, either we have to implement foreground service or we have to use job scheduler etc.

    0 讨论(0)
提交回复
热议问题