1

Out application is for samsung watch gear s3. I already tried following code:

function onchangedCB(pedometerInfo) {    
    console.log('accumulativeTotalStepCount: ' + pedometerInfo.accumulativeTotalStepCount);
    tizen.humanactivitymonitor.unsetAccumulativePedometerListener();
}

tizen.humanactivitymonitor.setAccumulativePedometerListener(onchangedCB);

In this data whatever I am getting is correct, But, in this code onchangedCB function will be called only when there is a change in activity (like Walking, Running) and I want total step count till the time at that movement only, I dont want to wait till next activity happen.

I also tried:

tizen.humanactivitymonitor.start("PEDOMETER",
        function onSuccess(pedometerInfo) {
                  console.log(pedometerInfo.cumulativeTotalStepCount)
        }
);
function onsuccessCB(pedometerInfo) {
     console.log("Accumulative total step count : " + pedometerInfo.accumulativeTotalStepCount);
}
function onerrorCB(error) {
     console.log("Error occurs. name:"+error.name + ", message: "+error.message);
}
tizen.humanactivitymonitor.getHumanActivityData("PEDOMETER", onsuccessCB, onerrorCB);

getHumanActivityData is returning data right away but unable to get accumulativeTotalStepCount.

Sandip patil
  • 123
  • 2
  • 14

1 Answers1

1

Unfortunately you cannot achieve your goal using humanactivity web API. As it stays in setAccumulativePedometerListener() API reference is is used to register listener for change of data ('when new data is available'). This makes clear that it is not your use-case.

getHumanActivityData() function is designed for returning the data since the latest call of start() for this sensor, which also does not meet your expectations about total steps count (accumulated).

I can only suggest you some workaround with getting accumulativeTotalStepCount when available in your application and cache it when closing your application. Then until your application will gather updated data, the result will be approximately accurate. And updated after first listener call.

EDIT: Necessary data is not available from Web API, but it could be provided using native API. You can also refer to hybrid application concept which uses Web application and native service which communicate with app and provides data

15kokos
  • 575
  • 2
  • 8
  • Thanks @15kokos , But if you install any watch face which is showing step count then you will be able to see step count right away(Without any event). So, how they are doing that? – Sandip patil Oct 15 '19 at 04:49
  • Necessary data is not available from Web API, but it could be provided using native API (https://developer.tizen.org/dev-guide/5.0.0/org.tizen.native.mobile.apireference/group__CAPI__SYSTEM__SENSOR__LISTENER__MODULE.html). You can also refer to hybrid application concept(https://developer.tizen.org/ko/community/tip-tech/packaging-hybrid-application?langredirect=1) which uses Web application and native service which communicate with app and provides data (https://developer.tizen.org/community/tip-tech/communication-within-tizen-hybrid-app) – 15kokos Oct 15 '19 at 06:03
  • Do you know which native function giving that data without listener? – Sandip patil Oct 17 '19 at 11:12
  • I suggest checking https://developer.tizen.org/dev-guide/2.3.1/org.tizen.tutorials/html/native/system/sensor_tutorial_n.htm tutorial. Basing on it, you can find that sensor_listener_read_data() function looks promising. It gathers data from sensor on demand (if data is not available, function fails). – 15kokos Oct 17 '19 at 11:31