Optimizing App-Initiated Network Use

  Network traffic initiated by your app can usually be significantly optimized, since you can plan for what network resources it needs and set a schedule for accessing them. By applying careful scheduling, you can create significant periods of rest for the device radio and, thereby, save power. There are several Android APIs that can help with network access scheduling, and some of these functions can coordinate network access for other apps, further optimizing battery performance.

  This lesson teaches you how to reduce battery consumption by applying techniques for optimizing app-initiated network traffic.

Batch and Schedule Network Requests

  https://youtu.be/Ecz5WDZoJok

  On a mobile device, the process of turning on the radio, making a connection, and keeping the radio awake uses a large amount of power. For this reason, processing individual requests at random times can consume significant power and reduce battery life. A more efficient approach is to queue a set of network requests and process them together. This allows the system to pay the power cost of turning on the radio just once, and still get all the data requested by an app.

  https://youtu.be/orlRuEwlDoM

  Using a network access scheduler API for queuing and processing your app data requests can significantly increase the power efficiency of your app. Schedulers conserve battery power by grouping requests together for the system to process. They can further improve efficiency by delaying some requests until other requests wake up the mobile radio, or waiting until the device is charging. Schedulers defer and batch network requests system-wide, across all apps on the device, which gives them an optimizing advantage over what any individual app can do.

Choosing a batch-and-scheduling API

  Android provides three different APIs for your app to batch and schedule network requests. For most operations, these techniques are functionally equivalent. These APIs are listed in the following table with the most highly recommended first.

Scheduler Requirements Implementation Ease
GCM Network Manager GCM Network Manager requires that your app use the Google Play services client library, version 6.1.11 or higher — use the latest available version. Straightforward
Job Scheduler Job Scheduler does not require Google Play services, but is available only when targeting Android 5.0 (API level 21) or higher. Straightforward
Sync Adapter for scheduled syncs Sync Adapter does not require the Google Play services client library and has been available since Android 2.0 (API level 5). Complex

  Note: For scheduled data synchronization, you should always prefer GCM Network Manager or Job Scheduler over Sync Adapter if your requirements allow it.

Allow System to Check for Connectivity

  One of the most serious and unexpected causes of battery drain is when a user travels beyond the reach of any cell tower or access point. In this situation, the user is typically not using their device, but they notice the device getting warm, and then see that the battery is low or has run out.

  In this scenario, the problem is that an app is running a background process that keeps waking up the mobile radio at regular intervals to search for a cellular signal, but finds none. Searching for a cell signal is one of the most power-draining operations there is.

  The way to avoid causing this kind of problem for a user with your app is to use a battery-efficient method for checking connectivity. For app-initiated network requests, use a scheduler, which automatically usesConnectivity Manager to check for connectivity before calling into your app. As a result, if there's no network, the Connectivity Manager conserves battery because it performs the connectivity check itself, without loading the app to run the check. Battery is further conserved because schedulers use exponential backoff to check for connectivity less frequently as time progresses.

Android 性能优化(8)网络优化( 4)Optimizing App-Initiated Network Use的更多相关文章

  1. Android性能优化系列---管理你的app内存

     文章出处:http://developer.android.com/training/articles/memory.html#YourApp Random-access memory(RAM)在任 ...

  2. Android 性能优化(4)Optimizing Layout Hierarchies:用Hierarchy Viewer和Layoutopt优化布局

    Optimizing Layout Hierarchies This lesson teaches you to Inspect Your Layout Revise Your Layout Use ...

  3. Android 性能优化的方面方面都在这儿

    又到周六了,鸿洋的不定期的周六放送又来了~~这次来谈谈性能优化吧.大家在工作中或多或少都会拿自家的应用和竞品app做比对,不可避免的需要做一些app性能优化的活.很多时候可能是策略上的调整,不过还是有 ...

  4. android app性能优化大汇总(google官方Android性能优化典范 - 第2季)

    Google前几天刚发布了Android性能优化典范第2季的课程,一共20个短视频,包括的内容大致有:电量优化,网络优化,Wear上如何做优化,使用对象池来提高效率,LRU Cache,Bitmap的 ...

  5. Android性能优化系列之App启动优化

    Android性能优化系列之布局优化 Android性能优化系列之内存优化 Android性能优化系列之apk瘦身 应用的启动速度缓慢是我们在开发过程中常常会遇到的问题,比方启动缓慢导致的黑屏.白屏问 ...

  6. Android 性能优化(5)网络优化 (1) Collecting Network Traffic Data 用Network Traffic tool :收集传输数据

    Collecting Network Traffic Data 1.This lesson teaches you to Tag Network Requests 标记网络类型 Configure a ...

  7. Android性能优化问题总结

    性能优化这块,分为UI性能优化.内存优化.数据库优化.网络优化.耗电优化等等.可以从1.如何发现问题,2.怎么解决问题,3.解决效果对比,这几个方面去描述.举个简单例子——UI优化,可以从 UI出现什 ...

  8. Android性能优化之渲染

    Google近期在Udacity上发布了Android性能优化的在线课程,目前有三个篇章,分别从渲染,运算与内存,电量三个方面介绍了如何去优化性能,这些课程是Google之前在Youtube上发布的A ...

  9. Android 性能优化探究

    使用ViewStub动态载入布局.避免一些不常常的视图长期握住引用: ViewStub的一些特点: 1. ViewStub仅仅能Inflate一次,之后ViewStub对象被置空:某个被ViewStu ...

  10. 我把阿里、腾讯、字节跳动、美团等Android性能优化实战整合成了一个PDF文档

    安卓开发大军浩浩荡荡,经过近十年的发展,Android技术优化日异月新,如今Android 11.0 已经发布,Android系统性能也已经非常流畅,可以在体验上完全媲美iOS. 但是,到了各大厂商手 ...

随机推荐

  1. Delphi XE4 inline 的用法

    为了提高应用程序的性能,可以用inline声明一个函数过过程,对于声明为inline的过程,编译器在编译时,会取代正常的过程调用方式,取而代之是直接把这个函数的编译代码拿过来生成到调用该过程的地方,有 ...

  2. Just a Hook-HDU1698(线段树求区间)

    http://acm.hdu.edu.cn/showproblem.php?pid=1698 Problem Description In the game of DotA, Pudge’s meat ...

  3. 洛谷 U41572 Portal2

    U41572 Portal2 题目背景 某地ENLIGHTENED的XM研究所正在研究Portal的处理法则,想要揭示XM能量的来源以及应用XM能量.ENLIGHTENED的首席科学家Jacks发现其 ...

  4. OJ(Online Judge)

    OJ:它是Online Judge系统的简称,用来在线检测程序源代码的正确性.著名的OJ有RQNOJ.URAL等.国内著名的题库有北京大学题库.浙江大学题库等.国外的题库包括乌拉尔大学.瓦拉杜利德大学 ...

  5. c++命令提示符窗体下打印指定大小的菱形代码

    c++命令提示符窗体下打印指定大小的菱形代码 VS2010下,新建空项目.加入源文件,将代码粘贴进去就能够了. 通过改maxRows值的大小,能够控制菱形的大小 #include <stdio. ...

  6. BZOJ 2208 JSOI2010 连通数 Tarjan+拓扑排序

    题目大意:给定一个n个点的有向图,求有多少点对(x,y),使x沿边可到达y 设f[i][j]为从i到j是否可达 首先强联通分量中的随意两个点均可达 于是我们利用Tarjan缩点 缩点之后是一个拓扑图. ...

  7. 向海量用户发送数据哪家最强?上QDN下载LTE Broadcast SDK!

    情境一: 在一个数万人的体育场内.作为一名观众你非常难看清运动员的面容.假设有了4G手机.你能够非常easy的打开直播应用.一边看直播讲解,一边体验现场气氛.但令人尴尬的是,现场几万人同一时候须要观看 ...

  8. xenserver PXE安装系统错误的解决

    刚开始在xenserver里找pxe启动安装系统找了半天,最后在NEW VM里的template里选择other install  media 里找到pxe启动,启动之后加载映像,安装到一半又停止了, ...

  9. 1.jdk安装和环境配置

    这个简单,但是记不住,非要网上搜一遍不可: 1.打开我的电脑--属性--高级--环境变量 2.新建系统变量JAVA_HOME 和CLASSPATH 变量名:JAVA_HOME 变量值:C:\Progr ...

  10. JavaScript总结01

    1 JavaScript 与 Java 的关系? 雷锋和雷峰塔的关系JavaScript和Java都与sun公司有合作,是借势Java 2 JavaScript 的特点是什么? 脚本语言(一种轻量级的 ...