Optimizing General Network Use

  In general, reducing the amount of network traffic helps reduce battery drain. In addition to the battery-optimization techniques of the previous lessons, you should look at these general-purpose techniques and see if you can apply them to your app.

  This lesson briefly covers techniques that you can use to lower network traffic and consequently reduce the battery drain caused by your app.

Compress Data

  https://youtu.be/IwxIIUypnTE

  Reducing the amount of data sent or received over a network connection also reduces the duration of the connection, which conserves battery. You can:

  • Compress data, using a compression technique such as GZIP compression.
  • Use succinct data protocols. While JSON and XML offer human-readability, and language-flexibility, they are bandwidth-heavy formats, with high serialization costs in the Android platform. Binary serialization formats, such as Protocol Buffers or FlatBuffers offer a smaller on-the-wire packet size, as well as faster encoding and decoding time. If your application transfers a lot of serialized data on a regular basis, these formats can yield benefits for decoding time and transfer size.

Cache Files Locally

  https://youtu.be/7lxVqqWwTb0

  Your app can avoid downloading duplicate data by caching. Always cache static resources, including on-demand downloads such as full size images, and cache them for as long as reasonably possible.

  For example, you should consider this approach for a networked app that displays data from user-initiated network requests as the primary content on the screen. When the user opens this screen the first time, the app should display a splash screen. Subsequent loads should initially load with the data that was cached from the last network request. The screen reloads with new data once the network request is complete.

  To learn about caching, watch the video. To implement caching in your app, see Cache Files Locally.

Optimize Pre-Fetch Cache Size

  Optimize pre-fetch cache size based on local file system size and current network connectivity. You can use the connectivity manager to determine what type of networks (Wi-FI, LTE, HSPAP, EDGE, GPRS) are active and modify your pre-fetching routines to minimize battery load.

  For more information, see Use Modifying your Download Patterns Based on the Connectivity Type.

最新文章

  1. HAOI2015 泛做
  2. 2012 Multi-University #8
  3. python celery + redis
  4. Encrypt
  5. CentOS 7 运行级别切换
  6. SEL方法选择器
  7. IT书籍的选择与阅读
  8. R语言日期时间函数
  9. retrofit2 使用教程 及 Android 网络架构搭建 (原创)
  10. rz/sz上传下载
  11. SpringMVC+Mybatis+Mysql实战项目学习--环境搭建
  12. SharePoint 2013 母版页修改后,无法添加应用程序
  13. OWIN的概念初接触
  14. 使用js做创建图片及删除图片 若有什么不对或不完整的地方,请大家提出来,谢谢
  15. CUDA 计算线程索引的一般公式
  16. java之beanutils使用
  17. UE4中Bebavior Tree中Delay及其后面代码失效的原因
  18. 004-redis-命令-哈希操作,列表操作
  19. 使用exe4j将java项目打成exe执行程序
  20. Java基础加强之并发(三)Thread中start()和run()的区别

热门文章

  1. linux 常见名词及命令(三)
  2. python 安装依赖几个问题---HttpScan
  3. POJ 3686_The Windy's
  4. SOJ 2800_三角形
  5. CentOS7下安装单机版RabbitMQ及权限赋予
  6. 搬砖--杭电校赛(dfs)
  7. spring history &design Philosophy
  8. react 服务器端渲染 ssr 中 localstorage/history/window is not defined 解决方案
  9. JMS消息中间件原理及ActiveMQ用法
  10. 关于使用data()获取自定义属性出现undefined的说明