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. ...
随机推荐
- [JLOI2008]提示问题
题目描述 最近在JLOI网上的一个流行游戏中,选手要回答很难的问题.假如在规定时间内不能回答,系统将给出1个提示,之后再依次给出第2,3个提示.出现在答案中的是字母和下列字符: '.',',',':' ...
- UVA 11400_ Lighting System Design
题意: 给定一系列灯泡的额定功率,电源价钱,一个灯泡的价格以及系统所需该种灯泡的数量.已知流过灯泡的电流相等,所以为省钱可以将电压小的灯泡换成电压大的灯泡,但是不能换成电压更小的灯泡,问最少要花多少钱 ...
- [bzoj2229][Zjoi2011]最小割_网络流_最小割树
最小割 bzoj-2229 Zjoi-2011 题目大意:题目链接. 注释:略. 想法: 在这里给出最小割树的定义. 最小割树啊,就是这样一棵树.一个图的最小割树满足这棵树上任意两点之间的最小值就是原 ...
- Java使用Memcached和Redis简单示例
package xmq.study.memcached; import java.io.IOException; import java.net.InetSocketAddress; import n ...
- Rust 1.7.0 macro宏的复用 #[macro_use]的使用方法
Rust 1.7.0 中的宏使用范围包含三种情况: 第一种情况是宏定义在当前文件里.这个文件可能是 crate 默认的 module,也可能是随意的 module 模块. 另外一种情况是宏定义在当前 ...
- 移动端 js 实现图片上传 预览
方法一: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv=&q ...
- server证书安装配置指南(Tomcat 6)
一. 生成证书请求 1. 安装JDK 安装Tomcat须要JDK支持. 假设您还没有JDK的安装.则能够參考 Java SE Development Kit (JDK) 下载. 下载地址: ...
- 网页页面NULL值对浏览器兼容性的影响
网页页面NULL值对浏览器兼容性的影响 近期做项目中一个页面中的input radio出现浏览器兼容性问题. 主要问题: 在谷歌浏览器,360急速模式和搜狗急速模式中给radio初始动态赋 ...
- Android系统开发(4)——Autotools
Autotools工具的构成 1.autoscan autoscan是用来扫描源码文件夹生成configure.san文件的,configure.san包括了系统配置的基本选项.里面都是一些宏定义,我 ...
- Sping框架的IOC特性 悲观锁、乐观锁 Spring的AOP特性
Sping框架的IOC特性 IOC(Inversion of Control):控制反转 以下以课程与老师的安排来介绍控制反转. 一个合理的课程编排系统应该围绕培训的内容为核心,而不应该以具体的培训老 ...