运行android程序时显示stop,Android系统.应用程序关闭时WorkManager是否正在运行?
我想安排每晚數據庫更新.所以我使用新的Android WorkManager.我的理解是,一旦安排它將始終獨立于應用程序的生命周期在后臺運行.
是對的嗎?我的第一次測試顯示Work只在應用程序運行時執行.
val locationWork = PeriodicWorkRequest.Builder(UpdateDatabaseWorker::class.java, 24, TimeUnit.HOURS)
.addTag("DATABASE_UPDATE_SERVICE")
.build()
WorkManager.getInstance().enqueue(locationWork)
解決方法:
根據WorkManager bugtracker上報告的各種問題,他們的文檔并不完全準確地說明了在這種邊緣情況下WorkManager的確切行為.
On certain devices, apps are force stopped when the app is cleared from task manager, so that part is expected. … 07001
Unfortunately, some devices implement killing the app from the recents menu as a force stop. Stock Android does not do this. When an app is force stopped, it cannot execute jobs, receive alarms or broadcasts, etc. So unfortunately, it’s infeasible for us to address it – the problem lies in the OS and there is no workaround. 07002
The only issue that we have come across is the case where some Chinese OEMs treat swipe to dismiss from Recents as a force stop. When that happens, WorkManager will reschedule all pending jobs, next time the app starts up. Given that this is a CDD violation, there is not much more that WorkManager can do given its a client library. 07003
To add to this, if a device manufacturer has decided to modify stock Android to force-stop the app, WorkManager will stop working (as will JobScheduler, alarms, broadcast receivers, etc.). There is no way to work around this. Some device manufacturers do this, unfortunately, so in those cases WorkManager will stop working until the next time the app is launched. 07003
通過對具有庫存android的Pixel 2 XL進行強烈的OneTimeWorkRequest(無約束)測試,行為如下:
>任務經理關閉:
>工作繼續(稍后)
>重啟設備(正常運行):
>重啟完成后繼續工作
>應用信息“強制停止”:
>工作停止,只有在再次啟動應用程序時才會繼續
>重啟設備(工作是“強制停止”):
>在應用再次啟動之前,工作不會繼續
總結
以上是生活随笔為你收集整理的运行android程序时显示stop,Android系统.应用程序关闭时WorkManager是否正在运行?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux cached释放_正点原子L
- 下一篇: 上下级平台之间数据同步方案_Alluxi