当前位置: 首页>>代码示例>>Java>>正文


Java BatteryManager.BATTERY_HEALTH_DEAD属性代码示例

本文整理汇总了Java中android.os.BatteryManager.BATTERY_HEALTH_DEAD属性的典型用法代码示例。如果您正苦于以下问题:Java BatteryManager.BATTERY_HEALTH_DEAD属性的具体用法?Java BatteryManager.BATTERY_HEALTH_DEAD怎么用?Java BatteryManager.BATTERY_HEALTH_DEAD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.os.BatteryManager的用法示例。


在下文中一共展示了BatteryManager.BATTERY_HEALTH_DEAD属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: translateBatteryHealth

public static String translateBatteryHealth(int batteryHealth) {
    switch (batteryHealth) {
        case BatteryManager.BATTERY_HEALTH_UNKNOWN:
            return "UNKNOWN HEALTH";
        case BatteryManager.BATTERY_HEALTH_GOOD:
            return "GOOD";
        case BatteryManager.BATTERY_HEALTH_OVERHEAT:
            return "OVERHEAT";
        case BatteryManager.BATTERY_HEALTH_DEAD:
            return "DEAD";
        case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
            return "OVER VOLTAGE";
        case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
            return "UNSPECIFIED FAILURE";
        case BatteryManager.BATTERY_HEALTH_COLD:
            return "COLD";
        default:
            return "UNKNOWN (" + batteryHealth + ")";
    }
}
 
开发者ID:patrickfav,项目名称:under-the-hood,代码行数:20,代码来源:TypeTranslators.java

示例2: getHealthStatus

public String getHealthStatus() {
    String status = "";
    switch (mHealth) {
        case BatteryManager.BATTERY_HEALTH_UNKNOWN:
            status = "Unknown";
            break;
        case BatteryManager.BATTERY_HEALTH_GOOD:
            status = "Good";
            break;
        case BatteryManager.BATTERY_HEALTH_OVERHEAT:
            status = "Overheat";
            break;
        case BatteryManager.BATTERY_HEALTH_DEAD:
            status = "Dead";
            break;
        case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
            status = "Over Voltage";
            break;
        case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
            status = "Unspecified Failure";
            break;
    }

    return status;
}
 
开发者ID:greenhub-project,项目名称:batteryhub,代码行数:25,代码来源:DataEstimator.java

示例3: setHealth

private void setHealth(int healthValue) {
    String health;

    switch (healthValue) {
        case BatteryManager.BATTERY_HEALTH_GOOD:
            health = getString(R.string.battery_health_good);
            break;
        case BatteryManager.BATTERY_HEALTH_DEAD:
            health = getString(R.string.battery_health_dead);
            break;
        case BatteryManager.BATTERY_HEALTH_COLD:
            health = getString(R.string.battery_health_cold);
            break;
        case BatteryManager.BATTERY_HEALTH_OVERHEAT:
            health = getString(R.string.battery_health_overheat);
            break;
        case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
            health = getString(R.string.battery_health_over_voltage);
            break;
        case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
            health = getString(R.string.battery_health_unspecified);
            break;
        case BatteryManager.BATTERY_HEALTH_UNKNOWN:
        default:
            health = getString(R.string.battery_health_unknown);
    }

    mViewHealth.setValue(health);
    mBatteryInfo.setHealth(health);
}
 
开发者ID:Smart-Studio,项目名称:device-info,代码行数:30,代码来源:BatteryViewImpl.java

示例4: getBatteryHealth

public String getBatteryHealth() {
    String health = BATTERY_HEALTH_UNKNOWN;
    Intent intent = getBatteryStatusIntent();
    int status = intent.getIntExtra(BatteryManager.EXTRA_HEALTH, 0);
    switch (status) {
        case BatteryManager.BATTERY_HEALTH_COLD:
            health = BATTERY_HEALTH_COLD;
            break;

        case BatteryManager.BATTERY_HEALTH_DEAD:
            health = BATTERY_HEALTH_DEAD;
            break;

        case BatteryManager.BATTERY_HEALTH_GOOD:
            health = BATTERY_HEALTH_GOOD;
            break;

        case BatteryManager.BATTERY_HEALTH_OVERHEAT:
            health = BATTERY_HEALTH_OVERHEAT;
            break;

        case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
            health = BATTERY_HEALTH_OVER_VOLTAGE;
            break;

        case BatteryManager.BATTERY_HEALTH_UNKNOWN:
            health = BATTERY_HEALTH_UNKNOWN;
            break;

        case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
            health = BATTERY_HEALTH_UNSPECIFIED_FAILURE;
            break;
    }
    return health;
}
 
开发者ID:anitaa1990,项目名称:DeviceInfo-Sample,代码行数:35,代码来源:DeviceInfo.java

示例5: getHealth

/**
 * Method to resolve the battery health
 */
private void getHealth() {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "getHealth");
    }

    if (batteryIntent != null) {

        final SaiyResources sr = new SaiyResources(mContext, sl);

        final int health = batteryIntent.getIntExtra(BatteryManager.EXTRA_HEALTH,
                BatteryManager.BATTERY_HEALTH_UNKNOWN);

        switch (health) {

            case BatteryManager.BATTERY_HEALTH_COLD:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.cold));
                break;
            case BatteryManager.BATTERY_HEALTH_DEAD:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.dead));
                break;
            case BatteryManager.BATTERY_HEALTH_GOOD:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.good));
                break;
            case BatteryManager.BATTERY_HEALTH_OVERHEAT:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.over_heating));
                break;
            case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.over_voltage));
                break;
            case BatteryManager.BATTERY_HEALTH_UNKNOWN:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.currently_indeterminable));
                break;
            case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.currently_indeterminable));
                break;
            default:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.currently_indeterminable));
                break;
        }

        sr.reset();

    } else {
        if (DEBUG) {
            MyLog.w(CLS_NAME, "batteryIntent: null");
        }
        setAccessFailure();
    }
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:52,代码来源:BatteryInformation.java

示例6: getDetailedItems

public List<ItemDetails> getDetailedItems() {
    List<ItemDetails> detailedItems = new ArrayList<>();
    IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    Intent batteryStatus = sContext.registerReceiver(null, ifilter);
    //TODO: Change true to yes.
    detailedItems.add(new ItemDetails("Present",
            Boolean.valueOf(batteryStatus.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false)).toString()));
    detailedItems.add(new ItemDetails("Technology", batteryStatus.getStringExtra(BatteryManager.EXTRA_TECHNOLOGY)));
    detailedItems.add(new ItemDetails("Status", Integer.valueOf(batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1)).toString()));

    int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
    boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL;
    int chargePlug = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
    boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;
    boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;
    boolean wirelessCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_WIRELESS;
    String chargeType = "Not plugged";
    if(usbCharge) {
        chargeType = "USB Power";
    } else if(acCharge) {
        chargeType = "AC Power";
    } else if(wirelessCharge) {
        chargeType = "Wireless Power";
    }
    detailedItems.add(new ItemDetails("Charging", chargeType));

    int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
    int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

    float batteryPct = level / (float)scale;

    int health = batteryStatus.getIntExtra(BatteryManager.EXTRA_HEALTH, -1);

    String healthStatus = "";
    if(health == BatteryManager.BATTERY_HEALTH_GOOD) {
        healthStatus = "Good";
    } else if(health == BatteryManager.BATTERY_HEALTH_OVERHEAT) {
        healthStatus = "Over Heat";
    } else if(health == BatteryManager.BATTERY_HEALTH_DEAD) {
        healthStatus = "Dead";
    } else if(health == BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE) {
        healthStatus = "Over Voltage";
    } else if(health == BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE) {
        healthStatus = "Unspecified failure";
    } else if(health == BatteryManager.BATTERY_HEALTH_COLD) {
        healthStatus = "Cold";
    } else {
        healthStatus = "UNKNOWN";
    }
    //TODO: Decide if unsupported charger is attached.

    detailedItems.add(new ItemDetails("Health", healthStatus));
    detailedItems.add(new ItemDetails("Battery", Integer.valueOf((int)(batteryPct*100)).toString()+"%"));

    float temp = ((float) batteryStatus.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,0) / 10);

    detailedItems.add(new ItemDetails("Temperature", Float.valueOf(temp).toString()+"°C"));
    detailedItems.add(new ItemDetails("Voltage", Integer.valueOf(batteryStatus.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1)).toString()+"mV"));

    return detailedItems;
}
 
开发者ID:iamtrk,项目名称:Device-Explorer,代码行数:61,代码来源:Content.java


注:本文中的android.os.BatteryManager.BATTERY_HEALTH_DEAD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。