Firemonkey Android get battery level

  

By Flash Thunder I got a function:

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’), -1);
scale := battery.getIntExtra(StringToJString(‘scale’), -1);

result := (100 * level) div scale;
end;

But what should I pass as aContext param?

I need to get battery life every minute and save it to memo… …read more

Via: StackOverflow

Comments are closed.