One of the biggest drawbacks of the Android system is the power problem. Here we are in the download of optimization, as far as possible to achieve the purpose of saving electricity.
1. As far as possible to the data transmission, unrestricted read cache data will also increase the consumption of electricity. In general, taking data every 2-5 minutes, 1 to 5M is the best option, and you can avoid downloading duplicate data.
2. Use the Google Cloud messaging for Android (GCM) Push app update notification. This does not require you to establish a separate network connection for updates.
Update policy
Set a suitable frequency, it is best to allow users to modify the polling frequency.
private void Enablehttpresponsecache () {
try {
Long httpcachesize = 10 * 1024 * 1024; Ten MiB
File Httpcachedir = new file (Getcachedir (), "http");
Class.forName ("Android.net.http.HttpResponseCache")
. GetMethod ("Install", File.class, Long.class)
. Invoke (null, Httpcachedir, httpcachesize);
catch (Exception httpresponsecachenotavailable) {
LOG.D (TAG, "HTTP response cache is unavailable.");
}
}
Modify Network Connection mode
In most cases, Wi-Fi consumes less than 3G of electricity.
Networkinfo activenetwork = Cm.getactivenetworkinfo ();
int prefetchcachesize = Default_prefetch_cache;
Switch (Activenetwork.gettype ()) {
Case Connectivitymanager.type_wifi:
... ...
Case Connectivitymanager.type_mobile:
... ...
Default:break;
}