uses AndroidAPI.JNI.GraphicsContentViewText,
AndroidAPI.JNI.JavaTypes,
AndroidAPI.JNI.OS; function BatteryPercent(const aContext: JContext): Integer;
var
filter: JIntentFilter;
battery: JIntent;
level, scale: Integer; begin filter := TJIntentFilter.Create;
filter.addAction(TJIntent.JavaClass.ACTION_BATTERY_CHANGED);
battery := aContext.registerReceiver(NIL, filter);
level := battery.getIntExtra(StringToJString('level'), -);
scale := battery.getIntExtra(StringToJString('scale'), -);
result := ( * level) div scale; end;
获取电池电量代码