如何在英文数字中获得电池广播值
我已经实现了Broadcast Receiver以获取关于电池电量,温度和电压细节的信息。
`private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){@Override public void onReceive(Context context,Intent intent){
batterylevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
tvPercent.setText(String.valueOf(batterylevel) + "%");
TEMP = ((float) intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,0)) / 10;
tv_temp.setText(TEMP +" C");
tvBiTmp.setText("Temprature "+TEMP +" C");
int voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE,0);
double fullVoltage = (double) (voltage * 0.001);
DecimalFormat decimalformat = new DecimalFormat("#.#");
VOLTAGE= Double.valueOf(decimalformat.format(fullVoltage));`
但是,如果Mobile的语言设置为可以说Marathi,印地语或阿拉伯语,而不是英语
在这种情况下,我得到Marathi的额外电压或阿拉伯数字值导致崩溃。
例如,如果接收到的电压值为4V,但如果可以说用户具有马拉(它可以阿拉伯语,西班牙语或其他),为语言设置,那么它被接收为4,其挑衅不可读用于int或字符串类
为此可以做些什么
链接地址: http://www.djcxy.com/p/63379.html上一篇: How to get Battery Broadcast Values in Only English Numerical
下一篇: Timer.schedule different in Activity and BroadcastReceiver