The vast majority of Android apps aren't architected in a way that delivers optimal networking performance, according to Google developer advocate Colt McAnlis. 

"Networking performance is one of the most important things that every one of your apps does wrong," he said during a talk he gave at Google's I/O developer conference in San Francisco.

Google Android characters ©iStock/juniorbeep
Google Android characters ©iStock/juniorbeep

By structuring the way apps access the network inefficiently, McAnlis said, developers are imposing needless costs in terms of performance and battery life - costs for which their users are on the hook.

"Bad networking costs your customers money,"  he said. "Every rogue request you make, every out-of-sync packet every two-bit image you request, the user has to pay for. Imagine if I went out and told them that."

The key to fixing the problem? Use the radio less, and don't move so much data around, McAnlis said.

One way to do this is batching, he said - architecting an app such that lower-priority data is sent when a device's networking hardware has been activated by something else, minimising the amount of time and energy used by the radio.

Pre-fetching data is another important technique for smoothing out network usage by Android apps, he said.

"If you can somehow sense that you're going to make six or seven requests in the future, don't wait for the device to go to sleep and then wake it up again - take advantage of the fact that the chip is awake right now, and make the requests right now," McAnlis said.

He also urged developers to use Google Cloud Messaging, rather than relying on server polling for updates.

"Polling the server is horrible.... It is a waste of the user's time," McAnlis said. "Think about this: Every time you poll the server and it comes back with a null packet, telling you that there's no new data, the user's paying for that."