Languages

Menu
Sites
Language
Getting battery level and status in galaxy s3 gear wearable web application

Hi,

I want to get the battery level in my galaxy s3 wearable web app. I was using the below code in tizen 2.3 application which was working fine. I updated the tizen version to 3.01 on my S3 gear recently. After the new update the below code is not working in my app.

Code

var rate = 1000;
var interval = window.setInterval(function(){
console.log("update battery info");
var battery = navigator.battery || navigator.webkitBattery || navigator.mozBattery;
var level = battery.level * 100;
},rate);

Could you please let me know if there is any other way to get the battery level and status in the new tizen(3.01) version?

Edited by: Sainath Morpoju on 26 Jun, 2018

Responses

3 Replies
Marco Buettner

use navigator.getBattery();

Marco Buettner

https://www.w3.org/TR/2016/CR-battery-status-20160707/#the-batterymanager-interface

Armaan-Ul- Islam

navigator.battery is deprecated, You have to use navigator.getBattery instead according to Tizen Web Debugger Tool:

As Marco Buettner mentioned.

This is common code for web tool, But the best solution for Tizen Wearable is to use Tizen Wearable Web: SystemInfo API to fetch System Information.

function onSuccessCallback (BatteryInfo) {
    var isCharging = BatteryInfo.isCharging;
    var gearBatteryLevel = (BatteryInfo.level * 100);
}

tizen.systeminfo.getPropertyValue("BATTERY",onSuccessCallback); 

 

For Further Documentations:

SystemInfo Web API References