Samsung Electronics logo

Activating Motion Notifications



Learning how to activate motion notifications for getting updated motion data is a basic motion management skill:

  1. To activate pedometer notifications:
    1. Define the action to be taken when the pedometer data changes. In the following example, the changed values are recorded in the console log:

      function onchangedCB(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);
      }
      
    2. To start listening to changes in the pedometer data, use the start() method to register the onchangedCB listener:

      webapis.motion.start("PEDOMETER", onchangedCB);
    3. To stop listening to the pedometer data changes, use the stop() method:

      webapis.motion.stop("PEDOMETER");
  2. To activate wrist-up notifications:
    1. Define the action to be taken when the user lifts a wrist to look at the watch device. In the following example, the changed values are recorded in the console log:

      function onchangedCB() 
      {
         console.log("Wrist-up");
      }
      
    2. To start listening to occurring wrist-up events, use the start() method to register the onchangedCB listener:

      webapis.motion.start("WRIST_UP", onchangedCB);
    3. To stop listening to occurring wrist-up events, use the stop() method:

      webapis.motion.stop("WRIST_UP");