Modifying your Download Patterns Based on the Connectivity Type
2013-04-17 09:27
369 查看
Use Wi-Fi
In most cases a Wi-Fi radio will offer greater bandwidth at a significantly lower battery cost. As a result, you should endeavor to perform data transfers when connected over Wi-Fi whenever possible.You can use a broadcast receiver to listen for connectivity changes that indicate when a Wi-Fi connection has been established to execute significant downloads, preempt scheduled updates, and potentially even temporarily increase the frequency of regular
updates as described in Optimizing Battery Life lesson
Determining and Monitoring the Connectivity Status.
Use Greater Bandwidth to Download More Data Less Often
When connected over a wireless radio, higher bandwidth generally comes at the price of higher battery cost. Meaning that LTE typically consumes more energy than 3G, which is in turn more expensive than 2G.This means that while the underlying radio state machine varies based on the radio technology, generally speaking the relative battery impact of the state change tail-time is greater for higher bandwidth radios.
At the same time, the higher bandwidth means you can prefetch more aggressively, downloading more data over the same time. Perhaps less intuitively, because the tail-time battery cost is relatively higher, it's also more efficient to keep the radio active
for longer periods during each transfer session to reduce the frequency of updates.
For example, if an LTE radio is has double the bandwidth and double the energy cost of 3G, you should download 4 times as much data during each session—or potentially as much as 10mb. When downloading this much data, it's important to consider the effect
of your prefetching on the available local storage and flush your prefetch cache regularly.
You can use the connectivity manager to determine the active wireless radio, and modify your prefetching routines accordingly:
ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); int PrefetchCacheSize = DEFAULT_PREFETCH_CACHE; switch (activeNetwork.getType()) { case (ConnectivityManager.TYPE_WIFI): PrefetchCacheSize = MAX_PREFETCH_CACHE; break; case (ConnectivityManager.TYPE_MOBILE): { switch (tm.getNetworkType()) { case (TelephonyManager.NETWORK_TYPE_LTE | TelephonyManager.NETWORK_TYPE_HSPAP): PrefetchCacheSize *= 4; break; case (TelephonyManager.NETWORK_TYPE_EDGE | TelephonyManager.NETWORK_TYPE_GPRS): PrefetchCacheSize /= 2; break; default: break; } break; } default: break; }
相关文章推荐
- Modifying your Download Patterns Based on the Connectivity Type
- Transferring Data Without Draining the Battery - Modifying your Download Patterns Based on the Conne
- CHANGING BEHAVIOR BASED ON THE VALUE OF AN ENUMERATED TYPE(ZT)
- 关于 Details On launch and content download, your app stores 15.83MB on the user's iCloud被拒问题
- Choosing App Localization For Your App Based On the Target Audience Of the Project
- Access restriction: The type ‘BASE64Decoder’ is not API (restriction on required library ‘D:\java\jd
- Dynamics CRM2016 The value of field on record of type entity is outside the valid range问题的解决方法
- Unity3D File Based Assetbundles on the iPhone
- 报错: Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library
- Farthest points Sampling on 3D meshes with mesh kept based on diffusion distance
- Access restriction: The type OutputFormat is not accessible due to restriction on required library D:/Java/jdk1.6.0_20/jre/lib/r
- The type XXX is not API (restriction on required library 'D:\jdk-64\jre\lib\rt.jar')
- The linux-- function hijacking -- Based on LD_PRELOAD
- Your project path contains non - ASCII characters. This will most likely cause the build to fail on
- 报错: Access restriction:The type JPEGCodec is not accessible due to restriction on required library
- 【论文:麦克风阵列增强】Speech Enhancement Based on the General Transfer Function GSC and Postfiltering
- 4.Your test database is running in NOARCHIVELOG mode. Which statement is true regarding the type of
- Android Dev Intro - An OpenGL ES renderer based on the GLSurfaceView rendering framework
- The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your.....
- The more you chase, the emptier your heart will be. On the 11-11 eve.