Answer the question
In order to leave comments, you need to log in
Why doesn't WorkManager work?
I'm trying to get the WorkManager to periodically launch the Logger.java service I wrote.
In MainActivity.java added to the onCreate method:
protected void onCreate(Bundle savedInstanceState) {
...
WorkManager.getInstance().enqueue(myWorkRequest);
PeriodicWorkRequest workRequest = new PeriodicWorkRequest.Builder(Logger.class, 15, TimeUnit.MINUTES, 15, TimeUnit.MINUTES).addTag("Logger").build();
WorkManager.getInstance().enqueueUniquePeriodicWork("Logger", ExistingPeriodicWorkPolicy.KEEP, workRequest);
...
}
Answer the question
In order to leave comments, you need to log in
Hypothesis: you run WorkManager as part of the Android UI process, that's where the problem comes from, it is possible that after the system kills the idle process, the WorkManager also stops (possibly with an error), because. he is part of the process.
Try running WorkManager as an asynchronous task or Thread.
There are some smart ideas here: microsin.net/programming/android/processes-and-thr...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question