简体   繁体   中英

Retrieve the battery drain level in Android

I have seen that some applications show the amount of mV/hour the battery is consuming. Is there a way of retrieving that info? Or those programs are periodically reading the ACTION_BATTERY_CHANGED intent,recording the voltage level and calculating the gradient?

getting the battery information

private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver()  {
  @Override
  public void onReceive(Context arg0, Intent intent) {          
     int level = intent.getIntExtra("level", 0); 
         System.out.println("battery level" + level);            
  }
};     

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM