public static int getBatteryAveragePower(final Context context) {
int voltage;
int current = 0;
Intent receiver =
context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
if (receiver == null) return -1;
voltage = receiver.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0);
BatteryManager manager = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
if (manager != null) {
current = manager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_AVERAGE);
}
return (voltage * current) / 1000000000;
}