禁用无线当电池电压3.4 [英] Disable Wifi when battery voltage is 3.4

查看:176
本文介绍了禁用无线当电池电压3.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的设备我想禁用无线网络时,电池电压归结到3.4。

For my device I want disable wifi when battery voltage level comes down to 3.4.

如何知道电池的电压为3.4编程?

How to know the battery voltage is 3.4 programmatically?

推荐答案

您必须得到 ACTION_BATTERY_CHANGED 粘意图和读取从那里电压:

You have to get the ACTION_BATTERY_CHANGED sticky intent and read the voltage from there:

IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent batteryStatus = getContext().registerReceiver(null, ifilter);

int voltage = batteryStatus.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1);
if(voltage>0 && voltage<3400){
    //disable wifi
}

这篇关于禁用无线当电池电压3.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆