Network
Energy Efficiency,User Conformity
Transferring data over a slower network connection will consume much more power then over a fast connection.
See: Coding for Life – Battery Life, That is
Energy Efficiency,User Conformity
It should be first checked which network connection we are on.
ConnectivityManager mConnectivity;
TelephonyManager mTelephony;
// Skip if no connection, or background data disabled
NetworkInfo info = mConnectivity.getActiveNetworkInfo();
if (info == null || !mConnectivity.getBackgroundDataSetting()) {
return false;
}
// Only update if WiFi or 3G is connected and not roaming
int netType = info.getType();
int netSubtype = info.getSubtype();
if (netType == ConnectivityManager.TYPE_WIFI) {
return info.isConnected();
} else if (netType == ConnectivityManager.TYPE_MOBILE
&& netSubtype == TelephonyManager.NETWORK_TYPE_UMTS
&& !mTelephony.isNetworkRoaming()) {
return info.isConnected();
} else {
return false;
}
Another approach is to give the user the choice (user preference), when high volume data transfer should be done, eg. only WiFi, 3G etc. A manual trigger of the update process might also be a solution.