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. ...
随机推荐
- EasyUI单击行数据时动态编写editor
$.extend($.fn.treegrid.methods, { addEditor: function (jq, param) { if (param instanceof Array) { $. ...
- Thinkphp5.0 的视图view的循环标签
Thinkphp5.0 的视图view的循环标签 volist标签: <!-- 使用volist --> <!-- name是传递过来的要循环变量名 --> <!-- k ...
- Kafka 生产消费 Avro 序列化数据
https://unmi.cc/kafka-produce-consume-avro-data/ https://unmi.cc/apache-avro-serializing-deserializi ...
- Ubuntu 16.04中iptables的工具简介(iptables/iptables-restore/iptables-xml/iptables-apply/iptables-save)
Ubuntu 16.04中安装的iptables版本为1.6.0,官方参考:http://www.linuxfromscratch.org/blfs/view/cvs/postlfs/iptables ...
- JSTL-SQL标签库
主页:http://www.cnblogs.com/EasonJim/p/6958992.html的分支页. 本章的前提需要先新建数据表及添加默认数据,脚本如下: -- -- 数据库: `test` ...
- ADSL和ITV
1.ADSL和ITV两者占用的是不同的虚通道,也就是使用不同的VLAN: 2.的确上通过不同的VPI/VCI来区分ADSL和ITV在不同通道,但不会互不影响的,因为使用的还是同一条线路的宽带速度: 3 ...
- linux network name space
linux network namespace概念类似于网络中的 VRF (virtual routing and forwarding).但是,你不知道VRF的概念也没关系,下面我们通过一个简单的介 ...
- Zookeeper学习 & Paxos
首先,Zookeeper是基于Paxos来进行分布式选举管理的,Paxos的内容可以参考我另一篇文章:http://www.cnblogs.com/charlesblc/p/6037004.html ...
- vsftpd.conf案例
1. 匿名服务器的连接(独立的服务器) 在/etc/vsftpd/vsftpd.conf配置文件中添加如下几项:Anonymous_enable=yes (允许匿名登陆)Dirmessage_enab ...
- C# .NET using ManagementObjectSearcher提示缺少引用怎么办
在下图中,即使引用了System.Management还是会出现报错 其实只要添加这条引用就可以了