Android battery when working with http

Google recently introduced the push-to-device service, but it is only available 2.2 or more.

I need a similar system in my application, and I'm trying to get around the limitations.

The problem is battery life. Since the user needs to immediately report changes on the server, I decided to implement a service that will live in the background (the standard Android service) and request a server for updates.

Of course, a server request, even every second, will cost a lot of bandwidth, as well as battery, so my question is: does it matter if the server holds the answer for a certain period of time? (idea of โ€‹โ€‹ajax request of type Comet)

It works as follows:

  • The device sends a data update request.
  • The server receives the request and goes into a cycle for one minute, checking for updates at each iteration
    • If there are updates, the server sends a response with updates
    • If not, the service proceeds to the next iteration.
  • After a minute, he finally sends a response that the data is not yet available.
  • After the response (whether empty or with data), Android launches another such request.

It will certainly cost less bandwidth, but will it consume less (or even more) battery?

+3
source share
2 answers

TCP (, , HTTP), , , . , , HTTP-. Bayeux HTTP push. , Android . , , . , , ( ), .

, , . , . - , , . , -. . , , - , HTTP ..

+2

, . , . , . , ? , ? . , , - , , .

, , , , , . , , , , . , , , , , , .

, , , , . , - (, WAIT_TIME 1 1 ) , ?

+1

Source: https://habr.com/ru/post/1783656/


All Articles