相关疑难解决方法(0)

Android BatteryManager替代品

我正试图在我的应用程序中获取电池统计信息以进行一些基准测试.精彩的BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER让我可以查询设备的微型放大器.但是,这仅在API 21中引入,因此可以达到的设备数量非常有限.是否有兼容的方法在较低版本的API(低至4.0)中执行类似的操作?我知道BatteryManager.EXTRA_LEVEL会给我百分比,但这真的不是细粒度的.

android battery usage-statistics

8
推荐指数
1
解决办法
1478
查看次数

以编程方式设备的总电池容量(mAh)

我已经尝试过Android的powerprofile ....我已经尝试过这个代码......但是每次在所有设备上都给我1000个答案...在android中有没有其他方法可以获得电池容量......例如移动设备容量为2000mAh应该还给我2000

public Double getBatteryCapacity() {

        Object mPowerProfile_ = null;
        double batteryCapacity = 0;
        final String POWER_PROFILE_CLASS = "com.android.internal.os.PowerProfile";
        try {
            mPowerProfile_ = Class.forName(POWER_PROFILE_CLASS)
                    .getConstructor(Context.class).newInstance(this);

        } catch (Exception e) {

            // Class not found?
            e.printStackTrace();
        }

        try {

            // Invoke PowerProfile method "getAveragePower" with param
            // "battery.capacity"
            batteryCapacity = (Double) Class.forName(POWER_PROFILE_CLASS)
                    .getMethod("getAveragePower", java.lang.String.class)
                    .invoke(mPowerProfile_, "battery.capacity");

        } catch (Exception e) {

            // Something went wrong
            e.printStackTrace();
        }

        return batteryCapacity;
    }
Run Code Online (Sandbox Code Playgroud)

java android battery batterymanager

6
推荐指数
2
解决办法
5272
查看次数

Android:无论如何要获得设备的电池容量吗?

我想让设备的电池容量做一些电池消耗计算,有可能以某种方式得到它吗?例如,三星Galaxy Note 2的电池容量为3100毫安.谢谢你的帮助.

android battery

5
推荐指数
1
解决办法
6062
查看次数