0

I am following this example, but my test fails, since workInfo.state is RUNNING instead of ENQUEUED. Does anyone know what might be the issue? Please let me know if I should provide more code/context.

shko
  • 64
  • 2
  • 20

1 Answers1

0

I have no idea why, but adding constraints to the request resolved the issue. It did not matter what constraints I set, it succeeded anyhow. That is, the test passed both with NetworkType.METERED and NetworkType.UNMETERED

val constraints = Constraints.Builder().setRequiredNetworkType(NetworkType.METERED).build()
val request = PeriodicWorkRequestBuilder<EchoWorker>(15, MINUTES)
        .setInputData(input)
        .setConstraints(constraints) // added this line
        .build()
shko
  • 64
  • 2
  • 20