[英]How do I ensure that my app keeps working regardless of phone state?
I'm trying to make an app with some scheduled tasks and an accessibility service logging info behind it.我正在尝试制作一个带有一些计划任务和它背后的辅助功能服务日志信息的应用程序。
The problem I see right now is that my tasks, which I use WorkManager
to run the Workers
at the time of the event, sometimes they don't run at the exact time I scheduled them to.我现在看到的问题是我的任务,我使用
WorkManager
在事件发生时运行Workers
,有时它们不会在我安排的确切时间运行。 I understand that this happens when the phone is using resources so Android pushes my task back to when it's free to do it, but how would I do it so that it always runs at the time I tell it to?我知道当手机正在使用资源时会发生这种情况,因此 Android 会将我的任务推回到可以自由执行的时间,但是我该怎么做才能让它始终在我告诉它的时候运行?
I've looked into it and found AlarmManager
with the setExactAndAllowWhileIdle
property could be of use, but I read in the docs that there's a limit to how many times this can run.我看着了一下,发现
AlarmManager
与setExactAndAllowWhileIdle
财产可能是使用的,但我在这有多少次这样可以运行一个限制文档阅读。 I've also looked into Quartz-Scheduler , but I have no idea whether this will work in these cases.我也研究过Quartz-Scheduler ,但我不知道这是否适用于这些情况。
The accessibility service has stopped working when not using my app for a long time too, and I imagine is the same problem (though not completely sure).长时间不使用我的应用程序时,辅助功能服务也停止工作,我想也是同样的问题(虽然不完全确定)。
Would disabling "Battery Optimisation" for my app help with all of this?为我的应用禁用“电池优化”是否有助于解决所有这些问题? Or what would be a good approach to it?
或者什么是一个好的方法?
Also there is a site with a summary of how different vendors work :还有一个网站总结了不同供应商的工作方式:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.