import Context from "android.content.Context"; import BatteryManager from "android.os.BatteryManager"; import { getAppContext } from "io.dcloud.uts.android"; export function getBatteryCapacity(): string { const context = getAppContext(); if (context != null) { const manager = context.getSystemService( Context.BATTERY_SERVICE ) as BatteryManager; const currentLevel: number = manager.getIntProperty( BatteryManager.BATTERY_PROPERTY_CAPACITY ); return '' + currentLevel + '%'; } return "0%"; }