简体   繁体   中英

Tizen Web App: readRecorderData TypeError: 'undefined' is not a function

I'm developing a Tizen web application for Gear Fit2 and i got an 'Type Error: undefined is not a function (tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror)' error when i called a "readRecorderData" function of a Human Activity API. However when i call a "start" function of the same API it works perfectly.

I put healthinfo and location privilege to my config.xml:

<tizen:privilege name="http://tizen.org/privilege/healthinfo"/>
<tizen:privilege name="http://tizen.org/privilege/location"/>

Hope you guys can help. Thanks.

There is a sample of my code that i used:

var type = 'PEDOMETER';
var now = new Date();
var startTime = now.setDate(now.getDate() - 7);
var anchorTime = (new Date(2018, 1, 2, 6)).getTime();
var query = {
  startTime: startTime / 1000,
  anchorTime: anchorTime / 1000,
  interval: 1440 /* 1 day */
};

try { tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror); } 
catch (err) { console.log(err.name + ': ' + err.message); }

The reason is your device runs on 2.3.1 or below Tizen OS version.

Check the API References Doc for readRecorderData(): Since 2.3.2

If you create a project with 2.3.2 (or above) tizen version and deploy on Tizen device or Emulator running on tizen 2.3.2 (or above) this error will be gone.

But for your case, HRM Recorder is supported from tizen 2.3.2 so you can't use it. Try a different workaround like storing sensor data in local storage or file system manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM