- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设我已经用 WorkManager 开始了这个 UniqueWork :-
var workContinuation: WorkContinuation = WorkManager.getInstance()
.beginUniqueWork(AppConstants.FILE_CREATOR_TAG,
ExistingWorkPolicy.APPEND,
firstOneTimeWorkRequest)
此时,我们的应用程序用户可能想要为其他任务启动另一个 UniqueWork 工作,但该任务应添加到上述工作任务的队列中。
var workContinuation: WorkContinuation = WorkManager.getInstance()
.beginUniqueWork(AppConstants.FILE_DISTRIBUTE_TAG,
ExistingWorkPolicy.APPEND,
fileDistrubuteTimeWorkRequest)
现在我如何告诉 WorkManager 这个 UniqueWork AppConstants.FILE_DISTRIBUTE_TAG 应该在这个 AppConstants.FILE_CREATOR_TAG 的队列中。
我不想使用 Observable 解决方案,在该解决方案中我可以跟踪此 AppConstants.FILE_CREATOR_TAG
工作人员完成并启动 AppConstants.FILE_DISTRIBUTE_TAG
。
最佳答案
您应该为两个工作人员指定相同的 uniqueWorkName
。引用 beginUniqueWork
documentation :
The
uniqueWorkName
uniquely identifies this set of work.If this method determines that new work should be enqueued and run, all records of previous work with
uniqueWorkName
will be pruned. If this method determines that new work should NOT be run, then the entire chain will be considered a no-op.If any work in the chain fails or is cancelled, all of its dependent work inherits that state and will never run. This is particularly important if you are using
APPEND
as your ExistingWorkPolicy.
因此,你的代码应该这样写:
var workContinuation: WorkContinuation = WorkManager.getInstance()
.beginUniqueWork(AppConstants.SOME_UNIQUE_NAME,
ExistingWorkPolicy.APPEND,
firstOneTimeWorkRequest)
// ...
var workContinuation: WorkContinuation = WorkManager.getInstance()
.beginUniqueWork(AppConstants.SOME_UNIQUE_NAME,
ExistingWorkPolicy.APPEND,
fileDistrubuteTimeWorkRequest)
关于android - 我们可以使用 WorkManager 在其他 UniqueWork 的队列中添加另一个 UniqueWork,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54705252/
我需要将复杂对象传递给 WorkManager。或者我需要序列化包含 Livedata 和 Date 的对象。 它抛出 java.lang.IllegalArgumentException: Keyc
是否可以对 worker 设置一些自定义约束(条件)? 就我而言,我希望仅当 Room 数据库的表中有一些数据可用时才执行工作程序。如果表不为空,我可以在数据库上观察并安排工作人员,但如果我可以在这种
与:实现“androidx.work:work-runtime:2.3.4” 我正在尝试实现自定义初始化以启用更详细的日志记录 according to these instructions . 第一
是 RECEIVE_BOOT_COMPLETED WorkManager 在重新启动后重新安排工作人员所需的权限?如果不是 WorkManager 如何处理这个? 最佳答案 Yes, it is. T
对于 OneTimeWorkRequest,我们可以使用 WorkContinuation 来确保如果作业已经安排好了,我们可以保留或替换它。PeriodicWorkRequest 没有这样的选项,因
我正在编写一个使用 WorkManager 的 Android 库。在代码的某处,我调用了这样的东西: val uploadTripRequest = OneTimeWorkRequest.Build
在某些设备上使用 WorkManager 计划的作业(100 例中有 1 例)根本没有执行。我安排工作: val constraints = Constraints.Builder() .se
我正在使用 workmanager 在我的应用程序中实现并行后台上传/下载功能。一切都很好,除了 WorkManager 同时运行太多作业并且电话变得无响应,直到事情停止。我想排队说 10 个任务,让
我在重新安排作业时遇到了 WorkManager 的问题。目前,我发现在使用 Okhttp 发起请求并在 AuthInterceptor 上引发错误后的某个时候,它会卡住并且不会启动其他作业。 这是管
我正在阅读有关 WorkManager ( https://developer.android.com/guide/background) 的信息。令我困惑的是这两个相互矛盾的陈述。它说应该使用 Wo
我想在 Worker 在后台运行时显示通知。我可以用下面的代码来做到这一点: override suspend fun doWork(): Result { val manager = Not
我正在构建一个功能,允许商家设置他们的业务时间表。这样的功能会自动改变变量 open至true和 false根据商家在一周中的每一天设定的时间。因此,总共有 14 个可能的不同时间。 我正在尝试使用新
我想在上传之前对媒体文件进行一些编辑,为此我使用了 FFMPEG 库。但是当 FFMPEG 执行带有回调的命令时。因此,WorkManager 甚至在 ffmpeg 命令完成之前就返回成功。我怎样才能
我按照官方指南使用 WorkManager(Kotlin 版本)设置了一个长期运行的 worker 。现在我需要用操作进度更新通知。 文档说: //需要更新时定期调用 setForegroundInf
是否有 WorkManager 的支持库版本。在 WorkManager 的发行说明中,有一个 pre androidx 版本 1.0.1 可用。 但是在添加与依赖相同的 implementation
我正在创建一个 Android 应用程序来在后台运行我的代码。我很清楚 Android Oreo 对后台服务引入的限制,这就是我使用 WorkManager API 来安排任务执行的原因。我正在使用
在初始化工作管理器并创建任一任务后,如果我们在任务执行中使用任何插件,则无法识别并抛出如下错误 MissingPluginException(在 channel lyokone/location 上找
在 websphere 中运行 spring 的 workmanager 任务执行器时收到异常。 以下是我的代码 我的 ConcurrentWorkManager 中的代码
我正在开发一个与网络上数百台设备交互的应用程序。提交的工作类型需要大量并发线程(主要是因为它们中的每一个都需要网络交互并且是单独进行的,但也有其他原因)。目前,我们所处的领域要求每个与之交互的设备大约
在我的应用中,用户可以启动后台进程,对后端进行长时间运行的 API 调用。用户还可以暂停后台线程并随时恢复。 如果应用重新启动,后台进程应该从它停止的地方恢复。后台进程完成后,该进程应终止。 即使后台
我是一名优秀的程序员,十分优秀!