1. 程式人生 > >Android獲取電池電量的三種方法

Android獲取電池電量的三種方法

BatteryManager batteryManager=(BatteryManager)getSystemService(BATTERY_SERVICE); System.out.println(batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)); System.out.println(batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_AVERAGE)); System.out.println(batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW
));