Answer the question
In order to leave comments, you need to log in
How to do HTTP-LongPolling via JetPack Workers?
I've been struggling with this problem for a long time now. The outcome is this: on Chinese phones in the background, everything falls off, or duplication of workers begins (which is rare).
Doing some testing in workers without networking (for example, sending notifications to the user in the background every minute) - everything works great. As I start working with the network in workers - that's it, there is a blockage. It is unknown how this happens.
public class LongPoll extends Worker {
public LongPoll(Context c, WorkerParameters p) {
super(c, p);
}
public Result doWork() {
try {
// здесь выполняется ожидающий запрос
} catch (Exception e) {}
// после выполнения HTTP-запроса запускаю повторную задачу
return Result.success();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question