Following are Java's Reflection APIs to retreive the value returned by getBatteryCapacity method of com.android.internal.os.PowerProfile :
Can anyone convert this to Delphi 12 syntax?
public double getBatteryCapacity(Context context) {
Object mPowerProfile;
double batteryCapacity = 0;
final String POWER_PROFILE_CLASS = "com.android.internal.os.PowerProfile";
try {
mPowerProfile = Class.forName(POWER_PROFILE_CLASS)
.getConstructor(Context.class)
.newInstance(context);
batteryCapacity = (double) Class
.forName(POWER_PROFILE_CLASS)
.getMethod("getBatteryCapacity")
.invoke(mPowerProfile);
} catch (Exception e) {
e.printStackTrace();
}
return batteryCapacity;
}