E
E
Evgeny Petrov2019-09-07 13:15:52
Java
Evgeny Petrov, 2019-09-07 13:15:52

How to keep in touch with the server in real time in android 8?

Hello!
There is a program that keeps in touch with the firebase in the background service (if the system kills the service, then the AlarmManager checks every 2 minutes if the service is running, if it is not running, then it starts). And when the data in firebase changes, new data instantly arrives on the device and the system sends a notification. Everything works perfectly.
But as you know, Android 8 limited the possibilities of the background service, according to which an alternative is needed. On stackoverflow they advise JobScheduler, like the best way. But, as I understand it, JobScheduler starts the task after a certain amount of time, i.e. this is not quite real time, the data in firebase may change now, and the device with the JobScheduler will respond, say, after a configured interval, i.e. e.g. after 2 minutes. How to make it so that it was in real time? I wonder how the same WhatsApp and other similar applications work. How to constantly listen to firebase?
Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2019-09-07
@sergey-gornostaev

How are applications such as Whatsapp, Viber, etc. synchronized with the server?

N
nApoBo3, 2019-09-07
@nApoBo3

Realtime is not about custom mobile operating systems and not about mobile communications.
In the general case, this is solved through push. You can also use the foreground service. But in any case, you need to understand that your service controls the OS and can kill it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question