[英]How can I get the value of charging current (in mA) in an android application?
我想在 Android 手機充電過程中測量電流(mA)的值。 如何讀取電流並將其顯示在我的應用程序中?
您可以使用BatteryManager類和BATTERY_PROPERTY_CURRENT_NOW
屬性讀取電池上的電流。
val mBatteryManager = this.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
val current = mBatteryManager.getLongProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW).div(1000)
請記住,這可能不適用於某些設備,例如三星、realme、華為。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.