How to get Battery Broadcast Values in Only English Numerical

I have implemented Broadcast Receiver for getting the information about the Battery level,Temperature and Voltage details.

`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));`

However if Mobile has Language set as lets say Marathi,Hindi,or Arabic which is other than English

in such case I get voltage Extra in Marathi or arabic Numeric Value which causes the crash .

For Example if Voltage Value received is 4 v but if lets say user has Marathi(it can arabic,spanish or another) as language set then it is received as ४ which defiantly not readable for int or string class

what could be done for this

链接地址: http://www.djcxy.com/p/63380.html

上一篇: 在实例启动时自动启动apache

下一篇: 如何在英文数字中获得电池广播值