Optimizing User-Initiated Network Use

This lesson teaches you to

  1. Pre-fetch Network Data
  2. Check for Connectivity or Listen for Changes
  3. Reduce the Number of Connections

  Quick handling of user requests helps ensure a good user experience, especially when it comes to user actions that require network access. You should prioritize low latency over power conservation to provide the fastest response when optimizing network use that is a direct result of user actions. Attaining an optimal network traffic profile for your app, while making sure that your users get fast responses, can be a bit challenging.

  This lesson teaches you how to optimize network use for user-initiated actions and reduce battery consumption.

Pre-fetch Network Data

  https://youtu.be/Rk1u7VVmadE

  Pre-fetching data is an effective way to reduce the number of independent data transfer sessions that your app runs. With pre-fetching, when the user performs an action in your app, the app anticipates which data will most likely be needed for the next series of user actions and fetches that data in bulk. Battery power consumption is reduced for two reasons:

  • Because your app pre-fetches data only when the the mobile radio is already awake from the user's action, and so does not incur the overhead of waking up the mobile radio.
  • The app pre-fetches data for anticipated user actions, each of which might otherwise require separate requests that each incur waking up the mobile radio.

  Tip: To explore whether your app might benefit from pre-fetching, review your app's network traffic and look for situations where a specific series of user actions almost always results in multiple network requests over the course of the task. For instance, an app that incrementally downloads article content as a user views it might be able to pre-fetch one or more articles in categories the user is known to view.

  Watch the video on effective pre-fetching which describes what pre-fetching is, where to use it, and how much data to pre-fetch. For more details, see Optimizing Downloads for Efficient Network Access.

Check for Connectivity or Listen for Changes

  Searching for a cell signal is one of the most power-draining operations on a mobile device. Your app should always check for connectivity before sending a user-initiated network request. If you use a scheduling service,Schedulers do this automatically for you.

  • If only certain buttons in your activity depend on a network connection, use Connectivity Manager to check for a network connection before sending the network request, as instructed in Monitor for Changes in Connectivity. If there's no network, the app can save battery by not forcing the mobile radio to search.
  • If your entire activity's user interface is non-functional without network access, then use Manipulate Broadcast Receivers on Demand. This technique listens for connectivity changes when your activity is in the foreground, and prevents network requests from proceeding when no connectivity exists. That is, if your app detects that connectivity has been lost, it disables all of its receivers, except for the connectivity-change receiver. An example would be a news app that presents an activity with a full-screen view of news snippets and does no pre-fetching. Any snippet a user taps would require a network connection.

  A best practice for user-initiated traffic is to first check for a connection using Connectivity Manager, and if there is no connection, schedule the network request for when the connection is made. Schedulers will use techniques such as exponential backoff to save battery, where each time the attempt to connect fails, the scheduler doubles the delay before the next retry.

  Note: To check for connectivity for app-initiated traffic, see Optimizing App-Initiated Network Use.

Reduce the Number of Connections

  In general, it's more efficient to reuse existing network connections than to initiate new ones. Reusing connections also allows the network to more intelligently react to congestion and related network data issues. For more information on reducing the number of connections used by your app, see Optimizing Downloads for Efficient Network Access.

Android 性能优化(7)网络优化( 3) Optimizing User-Initiated Network Use的更多相关文章

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

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

  2. Android性能优化典范第二季

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

  3. Android性能优化典范(二)

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

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

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

  5. Android性能优化典范 - 第2季

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

  6. Android性能优化问题总结

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

  7. Android性能优化之渲染

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

  8. Android 性能优化探究

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

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

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

  10. 【腾讯Bugly干货分享】Android性能优化典范——第6季

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/580d91208d80e49771f0a07c 导语 这里是Android性能优 ...

随机推荐

  1. UVA 1995 I can guess the structer

    模 拟 /*by SilverN*/ #include<algorithm> #include<iostream> #include<cstring> #inclu ...

  2. 硬盘安装Win 7系统Windows 7 系统硬盘安装教程(图解)

    目前,win 7的市场占有率即将超过XP成为了第一大系统,很多人也用上了win 7,你是不是也还是徘徊呢?是否因为XP用习惯了,或者是不会安装 win7呢?win7安装其实不麻烦,不管是什么系统,安装 ...

  3. ***CodeIgnite/CI 去掉 index.php的 配置

    CI有效删除URL中的index.php 参考: http://codeigniter.org.cn/forums/thread-15444-1-1.html 读CI的使用手册的话,关于如何有效删除U ...

  4. Educational Codeforces Round 41 B、C、D

    http://codeforces.com/contest/961 B题 可以将长度为k的连续区间转化成1 求最大和 解析 简单尺取 #include <stdio.h> #include ...

  5. CodeForces - 812C Sagheer and Nubian Market 二分

    On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friend ...

  6. POJ 2135_Farm Tour

    题意: 从出发点到目的地往返一次,道路i连接着ai号和bi号,长度为ci.同一条路只能走一次,求最小路径长度. 分析: 如果没有往返,那么就是简单的最短路问题.如果规定严格从左到右,那么就是简单的双调 ...

  7. 搬砖--杭电校赛(dfs)

    搬砖 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...

  8. 何为幻读?MySQL又是如何解决幻读的?

    一.什么是幻读 在一次事务里面,多次查询之后,查询的结果集的个数不一致的情况叫做幻读.而多出来或者少的哪一行被叫做 幻行 二.为什么要解决幻读 在高并发数据库系统中,需要保证事务与事务之间的隔离性,还 ...

  9. Python/Java程序员面试必备常用问题解析与答案

    转自AI算法联盟,理解python技术问题,以及一些常见的java面试中经常遇到的问题,这些面试问题分为四类: 是什么(what) 如何做(how) 说区别/谈优势(difference) 实践操作( ...

  10. Servlet基础教程:tutorialspoint-servlet

    来自turorialspoint的Servlet基础教程(英文),官网:https://www.tutorialspoint.com/servlets/index.htm 这个教程在国内已经被翻译成中 ...