如何获得剩余的电池估计时间?

时间:2020-02-26 05:28:53

标签: android android-studio

任何人都想得到电池的剩余时间和分钟数,请指导我...

this.level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
    this.scale = intent.getIntExtra(BatteryManager`enter code here`.EXTRA_SCALE, -1);
    this.temp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1);
    this.voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1);
    int temp=intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,0);

    TextView perc=((MainActivity)context).findViewById(R.id.battery_percentage_textview);
    TextView tem=((MainActivity)context).findViewById(R.id.temp_textview);
    TextView Remaninghours=((MainActivity)context).findViewById(R.id.batteryremaing_hours);
    TextView RemaingMin=((MainActivity)context).findViewById(R.id.batteryremaing_Minutes);


    int per=level*100/scale;



    perc.setText(per+" %");
    tem.setText( + (float)(temp/10) + " C");

0 个答案:

没有答案