C
C
ChernovDmitry2019-09-25 11:58:11
Android
ChernovDmitry, 2019-09-25 11:58:11

How to sync app with web service in new android versions?

In my Android application, there was periodic synchronization via android.content.SyncAdapter, data from the web service was updated every half an hour. For some reason, in new versions of android, it stopped working in the sense that synchronization only works when the application is on the screen and does not work when the system cuts it out. Google optimizes battery consumption)) As I understand it now, you need to do this all through WorkManger . And I can’t find a normal example anywhere, not with one-time work, but with constant synchronization of the application. Those. so that synchronization starts immediately when the application is installed and always works as long as the application is installed. Please show me a good example. Most of all, the question of where to insert the code for starting work is of interest, because this code itself is in the example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Varakosov, 2019-09-25
@ChernovDmitry

Well, if the official documentation is not enough for you, then here is a good description in Russian .
Otherwise, in new versions, the application cannot do anything if it has not been launched at least once. In addition, the synchronization period will not always be exactly 30 minutes, because the score is ruled by Doze - tasks are launched in bunches when the device wakes up. If you are placed in the GP, then you will be banned for bypassing Doze.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question