Android 电池状态侦听显示 电量 充电动态显示(3)

<span style="font-weight: bold; white-space: pre; ">  </span>switch (status) {                   case BatteryManager.BATTERY_STATUS_UNKNOWN:                       statusString = "unknown";                       break;                   case BatteryManager.BATTERY_STATUS_CHARGING:                       statusString = "charging";                       battery_image.setImageResource(R.drawable.stat_sys_battery_charge);                       battery_image.getDrawable().setLevel(level);                       break;                   case BatteryManager.BATTERY_STATUS_DISCHARGING:                       statusString = "discharging";                       battery_image.setImageResource(R.drawable.stat_sys_battery);                      battery_image.getDrawable().setLevel(level);                       break;                   case BatteryManager.BATTERY_STATUS_NOT_CHARGING:                       statusString = "not charging";                       break;                   case BatteryManager.BATTERY_STATUS_FULL:                       statusString = "full";                       break;                   }  

4.在onResume方法中注册消息处理器 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyxfjd.html