Samsung Electronics logo

Getting Motion Data



Learning how to retrieve the current motion data is a basic motion management skill:

  1. To get the current motion data, use the getMotionInfo() method:

    webapis.motion.getMotionInfo("PEDOMETER", onsuccessCB, onerrorCB);
  2. Use the success and error event handlers to define what to do with the data:

    function onsuccessCB(pedometerInfo) 
    {
       console.log("Step status: " + pedometerInfo.stepStatus);
       console.log("Cumulative calories: " + pedometerInfo.cumulativeCalorie);
       console.log("Cumulative distance: " + pedometerInfo.cumulativeDistance);
       console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount);
    }
    
    function onerrorCB(error) 
    {
       console.log("Error occurs");
    }