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. ...
随机推荐
- 【BZOJ2142】礼物(扩展lucas定理,中国剩余定理合并方程)
题意:有n件礼物,m个人,每个人分别需要w[i]件礼物,求分礼物的不同方案数 mod P 提示:设P=p1^c1 * p2^c2 * p3^c3 * … *pt ^ ct,pi为质数. 1≤n≤10^ ...
- CURL不可以读写文件
最近在学ES(elastic search),参考http://www.learnes.net/里面翻译的官方权威指南(后面发现官网已经推出了中文版文档了).里面有的例子把访问ES的命令做了简化如下: ...
- Spring Cloud体系实现标签路由
如果你正在使用Spring Cloud体系,在实际使用过程中正遇到以下问题,可以阅读本文章的内容作为后续你解决这些问题的参考,文章内容不保证无错,请务必仔细思考之后再进行实践. 问题: 1,本地连上开 ...
- Mesos, Marathon, Docker 平台部署记录
Mesos, Marathon, Docker 平台部署记录 所有组件部署基于Ubuntu 14.04 x64 主机 IP 角色 master 192.168.1.3 Mesos Master, Ma ...
- ZOJ 3819 Average Score 水
水 Average Score Time Limit: 2 Seconds Memory Limit: 65536 KB Bob is a freshman in Marjar Univer ...
- appium desktop
Appium-desktop 下载地址:https://github.com/appium/appium-desktop/releases 一般功能 这些能力跨越多个驱动因素. 仅限Android 这 ...
- dorker 安装
http://www.docker.org.cn/book/install/install-docker-win7-win8-requirements-38.html1. 你先去下载Docker To ...
- 【面试加分项】java自己定义注解之解析注解
我之前的博客中说明过自己定义注解的声明今天我们来看看怎样对我们自己定义的注解进行使用. 1.我们在程序中使用我们的注解. 上一篇中我们自己定义了一个注解: @Target(ElementType.FI ...
- C++求解数组中出现超1/4的三个数字。
#include <iostream> using namespace std; //求x!中k因数的个数. int Grial(int x,int k) { int Ret = 0; w ...
- Codeforces Round #323 (Div. 2) D. Once Again... 暴力+最长非递减子序列
D. Once Again... You a ...