Android 性能优化(10)网络优化( 6)Optimizing General Network Use
Optimizing General Network Use
This lesson teaches you to
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
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
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.
Android 性能优化(10)网络优化( 6)Optimizing General Network Use的更多相关文章
- Android 性能优化(4)Optimizing Layout Hierarchies:用Hierarchy Viewer和Layoutopt优化布局
Optimizing Layout Hierarchies This lesson teaches you to Inspect Your Layout Revise Your Layout Use ...
- Android 性能优化(6)网络优化( 2) Analyzing Network Traffic Data:分析网络数据
Analyzing Network Traffic Data 1.This lesson teaches you to Analyze App Network Traffic Analyze Netw ...
- Android性能优化典范(二)
Google前几天刚发布了Android性能优化典范第2季的课程,一共20个短视频,包括的内容大致有:电量优化,网络优化,Wear上如何做优化,使用对象池来提高效率,LRU Cache,Bitmap的 ...
- android app性能优化大汇总(google官方Android性能优化典范 - 第2季)
Google前几天刚发布了Android性能优化典范第2季的课程,一共20个短视频,包括的内容大致有:电量优化,网络优化,Wear上如何做优化,使用对象池来提高效率,LRU Cache,Bitmap的 ...
- Android性能优化典范 - 第2季
Google发布了Android性能优化典范第2季的课程,一共20个短视频,包括的内容大致有:电量优化,网络优化,Wear上如何做优化,使用对象池来提高效率,LRU Cache,Bitmap的缩放,缓 ...
- Android性能优化问题总结
性能优化这块,分为UI性能优化.内存优化.数据库优化.网络优化.耗电优化等等.可以从1.如何发现问题,2.怎么解决问题,3.解决效果对比,这几个方面去描述.举个简单例子——UI优化,可以从 UI出现什 ...
- Android性能优化之渲染
Google近期在Udacity上发布了Android性能优化的在线课程,目前有三个篇章,分别从渲染,运算与内存,电量三个方面介绍了如何去优化性能,这些课程是Google之前在Youtube上发布的A ...
- Android 性能优化探究
使用ViewStub动态载入布局.避免一些不常常的视图长期握住引用: ViewStub的一些特点: 1. ViewStub仅仅能Inflate一次,之后ViewStub对象被置空:某个被ViewStu ...
- android 性能优化
本章介绍android高级开发中,对于性能方面的处理.主要包括电量,视图,内存三个性能方面的知识点. 1.视图性能 (1)Overdraw简介 Overdraw就是过度绘制,是指在一帧的时间内(16. ...
随机推荐
- SaltStack学习系列之自定义grains
Master端 打开存放自定义grains的目录 vim /etc/salt/master file_roots: base: - /srv/salt/ 建立自定义模块 cd /srv/salt mk ...
- Node.js安装及环境配置之Windows篇(转:https://www.cnblogs.com/zhouyu2017/p/6485265.html)
Node.js安装及环境配置之Windows篇(原文地址:https://www.cnblogs.com/zhouyu2017/p/6485265.html) 一.安装环境 1.本机系统:Wind ...
- 状压DP问题
状态压缩·一 题目传送:#1044 : 状态压缩·一 AC代码: #include <map> #include <set> #include <list> #in ...
- Unity 5.x 导入教学Demo
前言 小巫也来玩Unity3D了.以后会把学习的一些过程博客记录下来,方大家也方便自己学习和查看.本篇博客介绍怎样在Unityclient中导入Assert Store中下载的项目资源,方便我们进一步 ...
- web 开发之js---js 实现网页中播放wav的一种方法(flash播放器)
http://blog.csdn.net/whumr1/article/details/6948160
- Android 4.4.2 动态加入JNI库方法记录 (一 JNI库层)
欢迎转载,务必注明出处.http://blog.csdn.net/wang_shuai_ww/article/details/44456755 本篇是继<s5p4418 Android 4.4. ...
- 【bzoj1042】[HAOI2008]硬币购物
首先使用DP预处理,先求出,在不考虑每种硬币个数的限制的情况下,每个钱数有多少种拼凑方案. 为了避免重复的方案被转移,所以我们以硬币种类为第一层循环,这样阶段性的增加硬币. 一定要注意这个第一层循环要 ...
- what is Servlet Container[转载]
1 在这个博客中,我将描述一下web服务器.Servlet容器的基本概念,以及Servlet容器和jvm之间的关系.我想要证明的是Servlet容器不过就是一个java程序. 2 什么是web服务器 ...
- 修改spring boot 启动logo
修改spring boot 启动logo 在项目添加文件banner.txt,将需要的logo写在里面 效果:
- H264--1--编码原理以及I帧B帧P帧[4]
---------------------- 前言 ----------------------- H264是新一代的编码标准,以高压缩高质量和支持多种网络的流媒体传输著称,在编码方面,我理解的他的理 ...