Effective Network Batching (Android Performance Patterns Season 3 ep10)

Android Developers · 12K views · 2015 · 3:26

Open on YouTube

Software performance & optimizationConsumer devices & gadgetsexplainerdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering questions about frequent polling or per-item API calls in Android apps, as a short explanation of why batching network requests saves battery.

Recommended by 2 people across 2 different months, 2015 to 2017.

What it is

A 3-minute Android Performance Patterns episode in which Colt McAnlis explains why networking is a major source of battery drain on mobile devices and why apps should batch network requests. It is a short, focused explainer from the Android Developers channel.

What people said

Recommends Colt McAnlis · 2015-08 · Stack Overflow · on “What's the "right" way to do polling in an android service in terms of timing(waiting), wifi and power locking”

Let's set the ground expectation about what battery resources are used for a REST grab. Battery cost to boot up the Radio chip [LINK] - this is a huge power spike Battery cost to keep the transfer the data [LINK] - this is a long-cost based upon the time taken to transfer data. For these two reasons, there's a lot of other suggestions to handle your implementation. Firstly, It's recommended to avoid doing polling [LINK] in favor of Google Cloud Messaging [LINK] . This allows the server to push information to the client ONLY when updates occur. This will cut down on your battery cost signifncantly. Secondly, if you can't use GCM (for example, you down control the server), then you need try an

Recommends Saeed Entezari · 2016-08 · Stack Overflow · on “Sending http requests from Android to server for every view in recyclerviewholder”

Consider persisting your information in local storage before overcalling the api. For example you can use OrmLite [LINK] (The one i'm using) or Realm [LINK] . After that you can batch every request you have and send it in one call instead of calling the api for each view visited. You can even schedule the task to be run when the user is not using your application. You can see this [this video] video for that. Hope it helps!

Cites Kurian Vithayathil · 2017-02 · Stack Overflow · on “Send location updates to firebase every 5 seconds?”

Firstly (if you haven't already) - check out Google's FusedLocationProviderApi [LINK] which is designed to be network/battery efficient when it comes to location updates. Also, have you looked in to GCM Network manager [LINK] ? This was designed to allow for battery efficient tasks (either one-off or recurring). It tries to batch those tasks them with other network requests to save multiple activiations of the device's radio. ( Here's a short explanation [this video] )