HumanActivityMonitor API

The Human Activity Monitor API defines interfaces and methods to manage human activity data from various sensors on the device.

The following human activity monitor functionality is provided:

  • Set up callbacks for data change notification
  • Get current human activity monitor data

For more information about how to use Human Activity Monitor API, see Human Activity Monitor Guide.

Since: 2.3

Table of Contents


Summary of Interfaces and Methods

Interface Method
HumanActivityMonitorManagerObject
HumanActivityMonitorManager
void getHumanActivityData (HumanActivityType type, HumanActivityMonitorSuccessCallback successCallback, optional ErrorCallback? errorCallback)
void start (HumanActivityType type, optional HumanActivityMonitorSuccessCallback? changedCallback)
StepDifference
HumanActivityData
HumanActivityPedometerData
HumanActivityAccumulativePedometerData
HumanActivityHRMData
HumanActivityGPSInfo
HumanActivityGPSInfoArray
HumanActivityMonitorSuccessCallback
void onsuccess (optional HumanActivityData? humanactivitydata)

1. Type Definitions

1.1. HumanActivityType

Specifies the supported human activity monitor types.
  enum HumanActivityType { "PEDOMETER", "WRIST_UP", "HRM", "GPS" };

Since: 2.3

The human activity monitor types defined by this enumerator are:

  • PEDOMETER - Pedometer data
  • WRIST_UP - Wrist up gesture
  • HRM - Heart rate monitor (Heart rate and RR interval)
  • GPS - GPS information (latitude, longitude and speed)

1.2. PedometerStepStatus

Specifies the pedometer user's current movement type.
  enum PedometerStepStatus { "NOT_MOVING", "WALKING", "RUNNING" };

Since: 2.3

  • NOT_MOVING - The user remains stationary
  • WALKING - The user is walking
  • RUNNING - The user is running

2. Interfaces

2.1. HumanActivityMonitorManagerObject

The HumanActivityMonitorManagerObject interface defines what is instantiated by the Tizen object. The tizen.humanactivitymonitor object allows access to the human activity data.
  [NoInterfaceObject] interface HumanActivityMonitorManagerObject {
    readonly attribute HumanActivityMonitorManager humanactivitymonitor;
  };
  Tizen implements HumanActivityMonitorManagerObject;

Since: 2.3

Attributes

  • readonly HumanActivityMonitorManager humanactivitymonitor
    Object representing a exif manager.

    Since: 2.3

2.2. HumanActivityMonitorManager

The HumanActivityMonitorManager interface provides methods to access human activity data.
  [NoInterfaceObject] interface HumanActivityMonitorManager {
    void getHumanActivityData(HumanActivityType type, HumanActivityMonitorSuccessCallback successCallback,
                              optional ErrorCallback? errorCallback) raises(WebAPIException);
    void start(HumanActivityType type, optional HumanActivityMonitorSuccessCallback? changedCallback) raises(WebAPIException);
    void stop(HumanActivityType type) raises(WebAPIException);
    void setAccumulativePedometerListener(HumanActivityMonitorSuccessCallback changeCallback) raises(WebAPIException);
    void unsetAccumulativePedometerListener() raises(WebAPIException);
  };

Since: 2.3

Methods

getHumanActivityData
Gets the current human activity data for certain human activity types.
void getHumanActivityData(HumanActivityType type, HumanActivityMonitorSuccessCallback successCallback,
                          optional ErrorCallback? errorCallback);

Since: 2.3

The start() method should be called to turn on the sensor before calling the getHumanActivityData() method. If not, ServiceNotAvailableError occurs.

If the given type is not supported on a device, NotSupportedError is thrown.

The ErrorCallback method is launched with these error types:

  • ServiceNotAvailableError: If the getHumanActivityData() method is called without previously calling the start() method

Privilege level: public

Privilege: http://tizen.org/privilege/healthinfo

Privilege level: public

Privilege: http://tizen.org/privilege/location

Remark: getHumanActivityData() method can only be used with the HRM and PEDOMETER types.

Remark: The 'http://tizen.org/privilege/location' privilege is required for only GPS type. That means that both 'http://tizen.org/privilege/healthinfo' and 'http://tizen.org/privilege/location' should be declared in config.xml file for GPS type. In other types, only 'http://tizen.org/privilege/healthinfo' should be declared.

Remark: This function may fail if it is called before the sensor is ready. In case of interval-driven sensors, it is recommended to call the function after at least one sensor event is delivered. Otherwise, applications can retry to call this function to be sure that the sensor is ready.

Parameters:

  • type: Human activity data type to read (HRM or PEDOMETER).
  • successCallback: Callback method to be invoked when the human activity data has been read.
  • errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type UnknownError, if registering the success callback fails because of an unknown error.

    • with error type NotSupportedError, if the given type is not supported on a device or by this method.

    • with error type SecurityError, if the application does not have the privilege to use this function.

Code example:

function onsuccessCB(pedometerInfo)
{
  console.log("Step status: " + pedometerInfo.stepStatus);
  console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount);
}

function onerrorCB(error)
{
  console.log("Error occurs, name: " + error.name + ", message: " + error.message);
}

function onchangedCB(pedometerdata)
{
  console.log("From now on, you will be notified when the pedometer data changes");
  /* To get the current data information. */
  tizen.humanactivitymonitor.getHumanActivityData("PEDOMETER", onsuccessCB, onerrorCB);
}

tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB);

Output example:

From now on, you will be notified when the pedometer data changes.
Step status: WALKING
Cumulative total step count: 100
start
Starts a sensor and registers a change listener to be called when new human activity data for a given human activity type is available.
void start(HumanActivityType type, optional HumanActivityMonitorSuccessCallback? changedCallback);

Since: 2.3

Privilege level: public

Privilege: http://tizen.org/privilege/healthinfo

Remark: When the CPU is in the power saving mode, the WRIST_UP event might not occur even though <tizen:setting background-support="enable" /> is declared in the config.xml file.

Remark: The "http://tizen.org/privilege/location" privilege is required for only the GPS type. That means that both "http://tizen.org/privilege/healthinfo" and "http://tizen.org/privilege/location" should be declared in config.xml file for the GPS type. For other types, only "http://tizen.org/privilege/healthinfo" should be declared.

Parameters:

  • type: Human activity type to register a listener for.
    • Conditional privilege: For using GPS value, privilege http://tizen.org/privilege/location (public level) is needed since Tizen 2.3.
  • changedCallback [optional] [nullable]: Callback method to be invoked when new human activity data is available
    Note that the listener is not called for the successful start of a human activity sensor.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type UnknownError, if registering the listener fails because of an unknown error.

    • with error type NotSupportedError, if the given type is not supported on a device.

    • with error type SecurityError, if the application does not have the privilege to use this function.

Code example:

function onchangedCB(pedometerInfo)
{
  console.log("Step status: " + pedometerInfo.stepStatus);
  console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount);
}

tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB);

Output example:

Step status: WALKING
Cumulative total step count: 100

Code example:

function onchangedCB(info)
{
  var gpsInfo = info.gpsInfo;
  for (var index = 0; index < gpsInfo.length; index++)
  {
    console.log("latitude: " + gpsInfo[index].latitude);
    console.log("longitude: " + gpsInfo[index].longitude);
  }
}

function onerrorCB(error)
{
  console.log("Error occurred, name: " + error.name + ", message: " + error.message);
}

try
{
  tizen.humanactivitymonitor.start(
      "GPS", onchangedCB, onerrorCB, {callbackInterval: 150000, sampleInterval: 1000});
}
catch (err)
{
  console.log(err.name + ": " + err.message);
}
stop
Stops the sensor and unregisters a previously registered listener for available human activity data.
void stop(HumanActivityType type);

Since: 2.3

Privilege level: public

Privilege: http://tizen.org/privilege/healthinfo

Remark: The "http://tizen.org/privilege/location" privilege is required for only the GPS type. That means that both "http://tizen.org/privilege/healthinfo" and "http://tizen.org/privilege/location" should be declared in config.xml file for the GPS type. For other types, only "http://tizen.org/privilege/healthinfo" should be declared.

Parameters:

  • type: Human activity type to unregister the listener for.
    • Conditional privilege: For using GPS value, privilege http://tizen.org/privilege/location (public level) is needed since Tizen 2.3.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type UnknownError, if unregistering the listener fails because of an unknown error.

    • with error type NotSupportedError, if the given type is not supported on a device.

    • with error type SecurityError, if the application does not have the privilege to use this function.

Code example:

tizen.humanactivitymonitor.stop("PEDOMETER");
setAccumulativePedometerListener
Starts the sensor and registers a listener to be called when new accumulative pedometer data is available.
void setAccumulativePedometerListener(HumanActivityMonitorSuccessCallback changeCallback);

Since: 2.3

Note that the setAccumulativePedometerListener() method does not need to call the sensor's start() method.

Privilege level: public

Privilege: http://tizen.org/privilege/healthinfo

Parameters:

  • changeCallback: Callback method to be invoked when new accumulative pedometer data is available
    Callback is invoked with HumanActivityAccumulativePedometerData as an argument.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    • with error type UnknownError, if registering the listener fails because of an unknown error.

    • with error type NotSupportedError, if the pedometer sensor is not supported on a device.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

function onchangedCB(pedometerInfo)
{
  console.log("Step status: " + pedometerInfo.stepStatus);
  console.log("Accumulative total step count: " + pedometerInfo.accumulativeTotalStepCount);
}

tizen.humanactivitymonitor.setAccumulativePedometerListener(onchangedCB);

Output example:

Step status: WALKING
Accumulative total step count: 100
unsetAccumulativePedometerListener
Stops the sensor and unregisters a previously registered listener for the accumulative pedometer data.
void unsetAccumulativePedometerListener();

Since: 2.3

Calling this function has no effect if listener is not set.

Privilege level: public

Privilege: http://tizen.org/privilege/healthinfo

Exceptions:

  • WebAPIException
    • with error type UnknownError, if unregistering the listener fails because of an unknown error.

    • with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

tizen.humanactivitymonitor.unsetAccumulativePedometerListener();

2.3. StepDifference

The StepDifference interface represents the count difference between steps and timestamp.
  [NoInterfaceObject] interface StepDifference {
    readonly attribute long stepCountDifference;
    readonly attribute long timestamp;
  };

Since: 2.3

Attributes

  • readonly long stepCountDifference
    Count difference between the steps.

    Since: 2.3

  • readonly long timestamp
    Timestamp in seconds.

    Since: 2.3

2.4. HumanActivityData

The HumanActivityData interface is a common abstract interface used by the different types of human activity data.
  [NoInterfaceObject] interface HumanActivityData {
  };

Since: 2.3

2.5. HumanActivityPedometerData

The HumanActivityPedometerData interface represents pedometer data.
  [NoInterfaceObject] interface HumanActivityPedometerData : HumanActivityData {
    readonly attribute PedometerStepStatus stepStatus;
    readonly attribute double speed;
    readonly attribute double walkingFrequency;
    readonly attribute double cumulativeDistance;
    readonly attribute double cumulativeCalorie;
    readonly attribute double cumulativeTotalStepCount;
    readonly attribute double cumulativeWalkStepCount;
    readonly attribute double cumulativeRunStepCount;
    readonly attribute StepDifference[] stepCountDifferences;
  };

Since: 2.3

Attributes

  • readonly PedometerStepStatus stepStatus
    The current movement type.

    Since: 2.3

  • readonly double speed
    Current speed in km/h.

    Since: 2.3

  • readonly double walkingFrequency
    Step count per second.

    Since: 2.3

  • readonly double cumulativeDistance
    Cumulative distance traveled since the last start() method call in meters.

    Since: 2.3

  • readonly double cumulativeCalorie
    Cumulative calories burnt since the last start() method call in kcal.

    Since: 2.3

  • readonly double cumulativeTotalStepCount
    Cumulative walking and running step count since the last start() method call.

    The value is the sum of cumulativeWalkStepCount and cumulativeRunStepCount.

    Since: 2.3

  • readonly double cumulativeWalkStepCount
    Cumulative walking step count since the last start() method call.

    Since: 2.3

  • readonly double cumulativeRunStepCount
    Cumulative running step count since the last start() method call.

    Since: 2.3

  • readonly StepDifference[] stepCountDifferences
    Array of the StepDifference.

    Since: 2.3

2.6. HumanActivityAccumulativePedometerData

The HumanActivityAccumulativePedometerData interface represents pedometer motion data since the device boot.
  [NoInterfaceObject] interface HumanActivityAccumulativePedometerData : HumanActivityData {
    readonly attribute PedometerStepStatus stepStatus;
    readonly attribute double speed;
    readonly attribute double walkingFrequency;
    readonly attribute double accumulativeDistance;
    readonly attribute double accumulativeCalorie;
    readonly attribute double accumulativeTotalStepCount;
    readonly attribute double accumulativeWalkStepCount;
    readonly attribute double accumulativeRunStepCount;
    readonly attribute StepDifference[] stepCountDifferences;
  };

Since: 2.3

Attributes

  • readonly PedometerStepStatus stepStatus
    Current movement type.

    Since: 2.3

  • readonly double speed
    Current speed in km/h.

    Since: 2.3

  • readonly double walkingFrequency
    Step count per second.

    Since: 2.3

  • readonly double accumulativeDistance
    Accumulative distance traveled since the device boot in meters.

    Since: 2.3

  • readonly double accumulativeCalorie
    Accumulative calories burnt since the device boot in kcal.

    Since: 2.3

  • readonly double accumulativeTotalStepCount
    Accumulative walking and running step count since the device boot.

    The value is the sum of accumulativeWalkStepCount and accumulativeRunStepCount.

    Since: 2.3

  • readonly double accumulativeWalkStepCount
    Accumulative walking step count since the device boot.

    Since: 2.3

  • readonly double accumulativeRunStepCount
    Accumulative running step count since the device boot.

    Since: 2.3

  • readonly StepDifference[] stepCountDifferences
    Array of the StepDifference.

    Since: 2.3

2.7. HumanActivityHRMData

The HumanActivityHRMData interface represents Heart Rate Monitor(HRM) data.
  [NoInterfaceObject] interface HumanActivityHRMData : HumanActivityData {
    readonly attribute long heartRate;
    readonly attribute long rRInterval;
  };

Since: 2.3

Attributes

  • readonly long heartRate
    Heart rate in beats per minute. When a user takes off the watch device, the heartRate is set to -3. When a user shakes the watch, the heartRate is set to -2.

    Since: 2.3

  • readonly long rRInterval
    Peak-to-peak interval in millisecond(s).

    Since: 2.3

2.8. HumanActivityGPSInfo

The HumanActivityGPSInfo interface represents GPS information.
  [NoInterfaceObject] interface HumanActivityGPSInfo {
    readonly attribute double latitude;
    readonly attribute double longitude;
    readonly attribute double altitude;
    readonly attribute double speed;
    readonly attribute long errorRange;
    readonly attribute long timestamp;
  };

Since: 2.3

Attributes

  • readonly double latitude
    An attribute to indicate the user's latitude in degrees.

    Since: 2.3

  • readonly double longitude
    An attribute to indicate the user's longitude in degrees.

    Since: 2.3

  • readonly double altitude
    An attribute to indicate the user's altitude in meters.

    Since: 2.3

  • readonly double speed
    An attribute to indicate the speed in km/h.

    Since: 2.3

  • readonly long errorRange
    An attribute to indicate the error range of the user's position in meters.

    Since: 2.3

  • readonly long timestamp
    An attribute to indicate timestamp in seconds.

    Since: 2.3

2.9. HumanActivityGPSInfoArray

The HumanActivityGPSInfoArray interface represents GPS information array.
  [NoInterfaceObject] interface HumanActivityGPSInfoArray : HumanActivityData {
    readonly attribute HumanActivityGPSInfo[] gpsInfo;
  };

Since: 2.3

Attributes

  • readonly HumanActivityGPSInfo[] gpsInfo
    An attribute to indicate the array of GPS information.

    Since: 2.3

2.10. HumanActivityMonitorSuccessCallback

The HumanActivityMonitorSuccessCallback interface is a callback interface that is invoked when new human activity data is available.
  [Callback=FunctionOnly, NoInterfaceObject] interface HumanActivityMonitorSuccessCallback {
    void onsuccess(optional HumanActivityData? humanactivitydata);
  };

Since: 2.3

Methods

onsuccess
Called when there is new human activity data available.
void onsuccess(optional HumanActivityData? humanactivitydata);

Since: 2.3

Parameters:

  • humanactivitydata [optional] [nullable]: New human activity data
    Note that null is passed for the WRIST_UP type.

3. Related Feature

Method tizen.systeminfo.getCapability() can be used in application runtime to check whether this API is supported.

To guarantee that the Human Activity Monitor application runs on a device which supports this API, declare the following feature requirements in the config file:

  • http://tizen.org/feature/humanactivitymonitor
  • To guarantee that the pedometer application runs on a device with pedometer, declare the following feature requirements in the config file:

  • http://tizen.org/feature/sensor.pedometer
  • To guarantee that the wrist-up gesture recognition application runs on a device with wrist up, declare the following feature requirements in the config file:

  • http://tizen.org/feature/sensor.wrist_up
  • To guarantee that the Heart Rate Monitor application runs on a device with heart rate monitor, declare the following feature requirements in the config file:

  • http://tizen.org/feature/sensor.heart_rate_monitor
  • To guarantee that the GPS batch information tracking application runs on a device with GPS batch feature, declare the following feature requirements in the config file:

  • http://tizen.org/feature/location.batch
  • For more information, see Application Filtering.

    4. Full WebIDL

    module HumanActivityMonitor {
      enum HumanActivityType { "PEDOMETER", "WRIST_UP", "HRM", "GPS" };
      enum PedometerStepStatus { "NOT_MOVING", "WALKING", "RUNNING" };
      Tizen implements HumanActivityMonitorManagerObject;
      [NoInterfaceObject] interface HumanActivityMonitorManagerObject {
        readonly attribute HumanActivityMonitorManager humanactivitymonitor;
      };
      [NoInterfaceObject] interface HumanActivityMonitorManager {
        void getHumanActivityData(HumanActivityType type, HumanActivityMonitorSuccessCallback successCallback,
                                  optional ErrorCallback? errorCallback) raises(WebAPIException);
        void start(HumanActivityType type, optional HumanActivityMonitorSuccessCallback? changedCallback) raises(WebAPIException);
        void stop(HumanActivityType type) raises(WebAPIException);
        void setAccumulativePedometerListener(HumanActivityMonitorSuccessCallback changeCallback) raises(WebAPIException);
        void unsetAccumulativePedometerListener() raises(WebAPIException);
      };
      [NoInterfaceObject] interface StepDifference {
        readonly attribute long stepCountDifference;
        readonly attribute long timestamp;
      };
      [NoInterfaceObject] interface HumanActivityData {
      };
      [NoInterfaceObject] interface HumanActivityPedometerData : HumanActivityData {
        readonly attribute PedometerStepStatus stepStatus;
        readonly attribute double speed;
        readonly attribute double walkingFrequency;
        readonly attribute double cumulativeDistance;
        readonly attribute double cumulativeCalorie;
        readonly attribute double cumulativeTotalStepCount;
        readonly attribute double cumulativeWalkStepCount;
        readonly attribute double cumulativeRunStepCount;
        readonly attribute StepDifference[] stepCountDifferences;
      };
      [NoInterfaceObject] interface HumanActivityAccumulativePedometerData : HumanActivityData {
        readonly attribute PedometerStepStatus stepStatus;
        readonly attribute double speed;
        readonly attribute double walkingFrequency;
        readonly attribute double accumulativeDistance;
        readonly attribute double accumulativeCalorie;
        readonly attribute double accumulativeTotalStepCount;
        readonly attribute double accumulativeWalkStepCount;
        readonly attribute double accumulativeRunStepCount;
        readonly attribute StepDifference[] stepCountDifferences;
      };
      [NoInterfaceObject] interface HumanActivityHRMData : HumanActivityData {
        readonly attribute long heartRate;
        readonly attribute long rRInterval;
      };
      [NoInterfaceObject] interface HumanActivityGPSInfo {
        readonly attribute double latitude;
        readonly attribute double longitude;
        readonly attribute double altitude;
        readonly attribute double speed;
        readonly attribute long errorRange;
        readonly attribute long timestamp;
      };
      [NoInterfaceObject] interface HumanActivityGPSInfoArray : HumanActivityData {
        readonly attribute HumanActivityGPSInfo[] gpsInfo;
      };
      [Callback=FunctionOnly, NoInterfaceObject] interface HumanActivityMonitorSuccessCallback {
        void onsuccess(optional HumanActivityData? humanactivitydata);
      };
    };