0

I have developed an android application which is continuously sync with server after 10 seconds interval of time. Everything is fine but it consumes high battery.

I have not implemented as such so many features: - Location Update - 2 or 3 threads - 1 service

But I am not understanding how can I optimize the battery usage and decrease the usage.

Android Dev
  • 5
  • 1
  • 5
  • I suggest that use sync when the device in not in sleep mode. `((PowerManager) getSystemService(Context.POWER_SERVICE)).isScreenOn()` – Shank Jul 04 '16 at 14:11
  • I answered a [similar question](http://stackoverflow.com/questions/28694878/battery-safe-coding/28711805#28711805) a year or so ago. Hope it helps. – Taylor Kidd Jul 07 '16 at 04:07

2 Answers2

0

performance matters

Pretty much you are keeping phone alive at 100% all the time. Start syncing in something like 5 mins or more or implement GCM

X3Btel
  • 1,408
  • 1
  • 13
  • 21
0

The biggest energy hog is the CPU. 4G is next in line. See the link I have in my above comment. A very common mistake is to spin while waiting for some event. This keeps the CPU awake and drags down the battery. Next is thinking that a shorter interval between events (e.g. hitting your server all the time) is going to get you better performance. This is rarely the case. You need to figure out how to minimize your monitoring rates (e.g. once every 10 seconds) but still have your app function properly. That gives the CPU, 4G, Wifi, etc, a chance to enter low power states which is what reduces energy consumption and increase battery lifetime.

Taylor Kidd
  • 1,463
  • 1
  • 9
  • 11