Hi,
On both emulator and real device this property always returns “infinity”
based on this snippet, it should be possible (https://developer.tizen.org/community/code-snippet/web-code-snippet/battery-status)
any suggestions?
Thanks,
Duncan
Hi,
On both emulator and real device this property always returns “infinity”
based on this snippet, it should be possible (https://developer.tizen.org/community/code-snippet/web-code-snippet/battery-status)
any suggestions?
Thanks,
Duncan
I suggest to use Tizen API to get battery data. Please look at that code snippet:
// Store listenerID to free it at exit.
var battery_listenerId = tizen.systeminfo.addPropertyValueChangeListener(“BATTERY” , function(sysinfo) {
var batt_level = sysinfo.level; // double
var batt_isCharging = sysinfo.isCharging; // boolean
var battery_LevelPercentage = parseInt(batt_level * 100.0);
// …
});
// Use tizen.systeminfo.removePropertyValueChangeListener(battery_listenerId ) to free if not need anymore.
According to: https://www.tizen.org/tv/web_device_api/systeminfo
Sorry, but thats not the question.
Level and charging (boolean) work, so does dischargingTime, it’s just returns “Infinity”…
Please look at here BatteryManager: dischargingTime property - Web APIs | MDN
This value is Infinity
if the battery is currently charging rather than discharging, or if the system is unable to report the remaining discharging time.
and
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Probably is not supported anymore.
Since Tizen 4.0 property timeToDischarge is available.
Hey, its looks like you were right to begin with, that method works…
Thanks Andrzej!
Here’s the working code (for anyone else with this issue):
function onSuccessCallback (BatteryInfo) {
var isCharging = BatteryInfo.isCharging;
var batteryLevel = (BatteryInfo.level * 100);
var batteryTime = BatteryInfo.timeToDischarge;
console.log("Battery is Charging: " + isCharging);
console.log("Battery Level is: " + batteryLevel);
console.log("Battery Time Remaining (minutes): " + batteryTime);
}
tizen.systeminfo.getPropertyValue("BATTERY",onSuccessCallback);
Nice to hear it works finally
Can I charge my Samsung galaxy s9 with an inverter generator while traveling?