Android 性能优化(9)网络优化( 5)Optimizing Server-Initiated Network Use
Optimizing Server-Initiated Network Use
This lesson teaches you to
Network traffic sent by server programs to your app can be challenging to optimize. A solution to this problem is for your appp to periodically poll the server to check for updates. This approach can waste network connection and power when your app starts up a device's radio, only to receive an answer that no new data is available. A far more efficient approach would be for the to notify your app when it has new data, but figuring out how to send a notification from your server to potentially thousands of devices was previously no easy feat.
The Google Cloud Messaging (GCM) service solves this communication problem by allowing your servers to send notifications to instances of your app wherever they are installed, enabling greater network efficiency and lowering power usage.
This lesson teaches you how to apply the GCM service to reduce network use for server-initiated actions and reduce battery consumption.
Send Server Updates with GCM
Google Cloud Messaging (GCM) is a lightweight mechanism used to transmit brief messages from an app server to your app. Using GCM, your app server uses a message-passing mechanism to notify your app that there is new data available. This approach eliminates network traffic that your app would perform, by not contacting a backend server for new data when no data is available.
An example use of GCM is an app that lists speaker sessions at a conference. When sessions are updated on your server, the server sends a brief message to your app telling it updates are available. Your app can then call the server to update the sessions on the device only when the server has new data.
GCM is more efficient than having your app poll for changes on the server. The GCM service eliminates unnecessary connections where polling would return no updates, and it avoids running periodic network requests that could cause a device's radio to power up. Since GCM can be used by many apps, using it in your app reduces the total number of network connections needed on a device and allows the device radio to sleep more often.
For more information about GCM and how to implement it for your app, see Google Cloud Messaging.
Note: When using GCM, your app can pass messages in normal or high priority. Your server should typically use normal priority to deliver messages. Using this priority level prevents devices from being woken up if they are inactive and in a low-power Doze state. Use high priority messages only if absolutely required.
Android 性能优化(9)网络优化( 5)Optimizing Server-Initiated 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 ...
- 【腾讯Bugly干货分享】Android性能优化典范——第6季
本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/580d91208d80e49771f0a07c 导语 这里是Android性能优 ...
- Android性能优化典范第二季
Google前几天刚发布了Android性能优化典范第2季的课程,一共20个短视频,包括的内容大致有:电量优化,网络优化,Wear上如何做优化,使用对象池来提高效率,LRU Cache,Bitma ...
- Android性能优化典范(二)
Google前几天刚发布了Android性能优化典范第2季的课程,一共20个短视频,包括的内容大致有:电量优化,网络优化,Wear上如何做优化,使用对象池来提高效率,LRU Cache,Bitmap的 ...
- Linux/Android 性能优化工具 perf
/***************************************************************************** * Linux/Android 性能优化工 ...
- 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 ...
随机推荐
- 2018/4/7 Mybatis源码结构概览
在观看Mybatis源码的过程中,有一点疑惑,就是Mybatis的缓存设计明显有问题,首先,Mybatis缓存分为两级,先说一级,生命周期为一个sqlsession,只有在查询相同方法时才会命中缓存, ...
- cdq分治入门--BZOJ1176: [Balkan2007]Mokia
对w*w,w<=2000000的矩形,一开始全是0(或一开始全是s),n<=170000个操作,每次操作:矩阵内某点加上一个数,查某一个子矩阵的和,保证修改数<=160000,询问数 ...
- linux 命令练习 2018-08-27
linux 命令练习 2018-08-27 uname 显示系统名字 [test@localhost ~]$ uname Linux uname -a 即列出linux的内核版本号 [test@ ...
- Servlet开发(1)
Servlet开发 Servlet引入: 百度百科详细servlet介绍: 重点概括:servlet运行在服务器上,处理用户请求. 我们使用response来获取一个写方法 PrintWriter o ...
- [bzoj1485][HNOI2009]有趣的数列_卡特兰数_组合数
有趣的数列 bzoj-1485 HNOI-2009 题目大意:求所有1~2n的排列满足奇数项递增,偶数项递增.相邻奇数项大于偶数项的序列个数%P. 注释:$1\le n\le 10^6$,$1\le ...
- HashSet源码分析2
package com.test1; import java.util.HashSet; import java.util.Iterator; import java.util.Set; public ...
- 菜鸟运维笔记:安装与配置Apacheserver
前几天在在阿里花了49.5买了一个月的主机. 试着好用再续费吧. 地域:青岛 可用区:青岛可用区A CPU:1核 内存:512MB 带宽:1Mbps 操作系统:CentOS 6.5 64位 云盾:是 ...
- Scala-LIST/Tuple/Map
环境: CentOS 6.3 LIST(列表) 代码: $ cat list.scala var mylist = List(1,2,3) println(mylist) var mylist1 = ...
- Maven+Mybatis+Spring+SpringMVC实现分页查询(附源代码)
以下小宝鸽将分享一篇Mybatis分页功能的博文,以下将给出具体的步骤.跟着博主的节奏肯定能实现.另外最后还会附上整个project的源代码.假设是没有使用过maven的猿友可自行下载相关的jar包就 ...
- .net Core使用Orcle官方驱动连接数据库 C#参考教程 http://www.csref.cn
.net Core使用Orcle官方驱动连接数据库 最近在研究.net Core,因为公司的项目用到的都是Oracle数据库,所以简单试一下.net Core怎样连接Oracle. Oracle官 ...