From: Lukasz Bardeli
+The gesture recognition API allows applications to be notified and react when the user performs different types of gestures, for example, when the device was tapped, shaken up, picked up or moved along axis.
+
+The activity recognition API allows applications to be notified and react when a user activity is recognized, for example, the user starts to run, walk or is in moving vehicle.
+
For more information about how to use Human Activity Monitor API, see Human Activity Monitor Guide.
Deprecated.
+ WRIST_UP is deprecated since Tizen 4.0. Use GestureType and addGestureRecognitionListener to monitor WRIST_UP gesture.
+
Since:
@@ -369,8 +401,8 @@ UNKNOWN - Sleep status could not be determined
Code example:
+ Since:
+ 4.0
+
+ Since:
+ 4.0
+
Since:
@@ -516,20 +620,20 @@ The ErrorCallback method is launched with these error types:
Code example: Code example: Code example: Code example: Code example: Code example: Code example:
-
@@ -94,9 +108,13 @@ For more information about how to use Human Activity Monitor API, see HumanActivityRecorderPressureData
@@ -201,6 +222,10 @@ For more information about how to use Human Activity Monitor API, see GestureData
+
+
+
@@ -208,15 +233,22 @@ For more information about how to use Human Activity Monitor API, see HumanActivityReadRecorderSuccessCallback
HumanActivityMonitorSuccessCallback
+
+
GestureRecognitionCallback
+
+1. Type Definitions
-1.1. HumanActivityType
enum HumanActivityType { "PEDOMETER", "WRIST_UP", "HRM", "GPS", "SLEEP_MONITOR" };
function onchangedCB(sleepInfo)
{
- console.log("Sleep status: " + sleepInfo.status);
- console.log("Timestamp: " + sleepInfo.timestamp);
+ console.log("Sleep status: " + sleepInfo.status);
+ console.log("Timestamp: " + sleepInfo.timestamp);
}
tizen.humanactivitymonitor.start("SLEEP_MONITOR", onchangedCB);
@@ -382,6 +414,74 @@ tizen.humanactivitymonitor.start("SLEEP_MONITOR", onchangedCB);
1.7. GestureType
+ enum GestureType { "GESTURE_DOUBLE_TAP", "GESTURE_MOVE_TO_EAR", "GESTURE_NO_MOVE", "GESTURE_PICK_UP",
+ "GESTURE_SHAKE", "GESTURE_SNAP", "GESTURE_TILT", "GESTURE_TURN_FACE_DOWN", "GESTURE_WRIST_UP" };
+
+
+ 1.8. GestureEvent
+ enum GestureEvent { "GESTURE_EVENT_DETECTED", "GESTURE_SHAKE_DETECTED", "GESTURE_SHAKE_FINISHED", "GESTURE_SNAP_X_NEGATIVE",
+ "GESTURE_SNAP_X_POSITIVE", "GESTURE_SNAP_Y_NEGATIVE", "GESTURE_SNAP_Y_POSITIVE", "GESTURE_SNAP_Z_NEGATIVE", "GESTURE_SNAP_Z_POSITIVE" };
+
+
+ 2. Interfaces
@@ -430,6 +530,10 @@ The tizen.humanactivitymonitor object allows access to the human activi
HumanActivityRecorderQuery? query,
HumanActivityReadRecorderSuccessCallback successCallback,
optional ErrorCallback? errorCallback) raises(WebAPIException);
+
+ boolean isGestureSupported(GestureType type) raises(WebAPIException);
+ long addGestureRecognitionListener(GestureType type, GestureRecognitionCallback listener, optional ErrorCallback? errorCallback, optional boolean? alwaysOn) raises(WebAPIException);
+ void removeGestureRecognitionListener(long watchId) raises(WebAPIException);
};
function onsuccessCB(pedometerInfo)
{
- console.log("Step status: " + pedometerInfo.stepStatus);
- console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount);
+ 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);
+ 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);
+ 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);
@@ -635,8 +739,8 @@ For other types, only 'http://tizen.org/privilege/healthinfo' should be d
function onchangedCB(pedometerInfo)
{
- console.log("Step status: " + pedometerInfo.stepStatus);
- console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount);
+ console.log("Step status: " + pedometerInfo.stepStatus);
+ console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount);
}
tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB);
@@ -651,26 +755,27 @@ tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB);
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);
- }
+ 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);
+ console.log("Error occurred. Name:" + error.name + ", message: " + error.message);
}
try
{
- tizen.humanactivitymonitor.start("GPS", onchangedCB, onerrorCB, {callbackInterval: 150000, sampleInterval: 1000});
+ tizen.humanactivitymonitor.start("GPS", onchangedCB, onerrorCB,
+ {callbackInterval: 150000, sampleInterval: 1000});
}
catch (err)
{
- console.log(err.name + ": " + err.message);
+ console.log(err.name + ": " + err.message);
}
function onchangedCB(pedometerInfo)
{
- console.log("Step status: " + pedometerInfo.stepStatus);
- console.log("Accumulative total step count: " + pedometerInfo.accumulativeTotalStepCount);
+ console.log("Step status: " + pedometerInfo.stepStatus);
+ console.log("Accumulative total step count: " + pedometerInfo.accumulativeTotalStepCount);
}
tizen.humanactivitymonitor.setAccumulativePedometerListener(onchangedCB);
@@ -844,7 +949,8 @@ tizen.humanactivitymonitor.setAccumulativePedometerListener(onchangedCB);
@@ -1054,6 +1160,9 @@ catch (error)
with error type AbortError, if the system operation was aborted.
tizen.humanactivitymonitor.unsetAccumulativePedometerListener();
+
+tizen.humanactivitymonitor.unsetAccumulativePedometerListener();
function errorCallback(error)
{
- console.log(error.name + ': ' + error.message);
+ console.log(error.name + ": " + error.message);
}
function listener(info)
{
- console.log('type: ' + info.type);
- console.log('timestamp: ' + info.timestamp);
- console.log('accuracy: ' + info.accuracy);
+ console.log("type: " + info.type);
+ console.log("timestamp: " + info.timestamp);
+ console.log("accuracy: " + info.accuracy);
}
try
{
- var listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback);
+ var listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback);
}
catch (error)
{
- console.log(error.name + ': ' + error.message);
+ console.log(error.name + ": " + error.message);
}
@@ -975,25 +1081,25 @@ var listenerId;
function errorCallback(error)
{
- console.log(error.name + ': ' + error.message);
+ console.log(error.name + ": " + error.message);
}
function listener(info)
{
- console.log('type: ' + info.type);
- console.log('timestamp: ' + info.timestamp);
- console.log('accuracy: ' + info.accuracy);
+ console.log("type: " + info.type);
+ console.log("timestamp: " + info.timestamp);
+ console.log("accuracy: " + info.accuracy);
- tizen.humanactivitymonitor.removeActivityRecognitionListener(listenerId, errorCallback);
+ tizen.humanactivitymonitor.removeActivityRecognitionListener(listenerId, errorCallback);
}
try
{
- listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback);
+ listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback);
}
catch (error)
{
- console.log(error.name + ': ' + error.message);
+ console.log(error.name + ": " + error.message);
}
+ with error type ServiceNotAvailableError, if the human activity recorder type is already started by any application of a package. +
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
Code example:
-var type = 'PRESSURE'; +var type = "PRESSURE"; var options = { - retentionPeriod: 1 /* 1 hour */ + retentionPeriod: 1 /* 1 hour */ }; + try { - tizen.humanactivitymonitor.startRecorder(type, options); + tizen.humanactivitymonitor.startRecorder(type, options); } catch (err) { - console.log(err.name + ': ' + err.message); + console.log(err.name + ": " + err.message); }
Code example:
-var type = 'PRESSURE'; +var type = "PRESSURE"; try { - tizen.humanactivitymonitor.startRecorder(type); + tizen.humanactivitymonitor.startRecorder(type); + /* Do something */ - /* Do something */ - - tizen.humanactivitymonitor.stopRecorder(type); + tizen.humanactivitymonitor.stopRecorder(type); } catch (err) { - console.log(err.name + ': ' + err.message); + console.log(err.name + ": " + err.message); }
Code example:
function onerror(error) { - console.log(error.name + ": " + error.message); + console.log(error.name + ": " + error.message); } function onread(data) { - for (var idx = 0; idx < data.length; ++idx) - { - console.log('startTime: ' + data[idx].startTime); - console.log('endTime: ' + data[idx].endTime); - console.log('calories: ' + data[idx].calorie); - } + for (var idx = 0; idx < data.length; ++idx) + { + console.log("startTime: " + data[idx].startTime); + console.log("endTime: " + data[idx].endTime); + console.log("calories: " + data[idx].calorie); + } } -var type = 'PEDOMETER'; +var type = "PEDOMETER"; var query = {}; try { - tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror); + tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror); } catch (err) { - console.log(err.name + ': ' + err.message); + console.log(err.name + ": " + err.message); }@@ -1246,6 +1355,216 @@ catch (err) +
isGestureSupported
+boolean isGestureSupported(GestureType type); +
+ Since: + 4.0 +
++This function allows to check whether a gesture type is supported on the current device. Some gestures may not be supported on some devices because of lack necessary sensors. +
+Parameters:
+Return value:
+ boolean true if the given gesture type is supported. +Exceptions:
++ with error type TypeMismatchError, if input parameter is not compatible with the expected type. +
+ with error type AbortError, if any error occurs. +
Code example:
+try +{ + var isSupported = tizen.humanactivitymonitor.isGestureSupported("GESTURE_PICK_UP"); + console.log("GESTURE_PICK_UP is " + (isSupported ? "supported" : "not supported")); +} +catch (error) +{ + console.log("Error " + error.name + ": " + error.message); +} ++
Output example:
GESTURE_PICK_UP is supported. ++
addGestureRecognitionListener
+long addGestureRecognitionListener(GestureType type, GestureRecognitionCallback listener, optional ErrorCallback? errorCallback, optional boolean? alwaysOn); +
+ Since: + 4.0 +
++The ErrorCallback method is launched with this error type: +
+Parameters:
+Return value:
+ long The watch ID used to remove the listener. +Exceptions:
++ with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter. +
+ with error type NotSupportedError, if the gesture recognition is not supported. +
+ with error type IOError, if adding listener failed. +
Code example:
+function listener(data) +{ + console.log("Received " + data.event + " event on " + new Date(data.timestamp * 1000) + " for " + data.type + " type"); +} + +function errorCallback(error) +{ + console.log(error.name + ": " + error.message); +} + +try +{ + var listenerId = tizen.humanactivitymonitor.addGestureRecognitionListener("GESTURE_SHAKE", listener, errorCallback, true); + console.log("Listener with id " + listenerId + " has been added"); +} +catch (error) +{ + console.log("Error " + error.name + ": " + error.message); +} ++
Output example:
Listener with id 1 has been added + Received GESTURE_SHAKE_DETECTED event on Thu Sep 01 2016 14:33:56 GMT+0200 (CEST) for GESTURE_SHAKE type ++
removeGestureRecognitionListener
+void removeGestureRecognitionListener(long watchId); +
+ Since: + 4.0 +
+Parameters:
+Exceptions:
++ with error type AbortError, if system error occurs while removing listener. +
Code example:
+function listener(data) +{ + console.log("Received " + data.event + " event on " + new Date(data.timestamp * 1000) + " for " + data.type + " type"); +} + +function errorCallback(error) +{ + console.log(error.name + ": " + error.message); +} + +try +{ + var listenerId = tizen.humanactivitymonitor.addGestureRecognitionListener("GESTURE_SHAKE", listener, errorCallback); + tizen.humanactivitymonitor.removeGestureRecognitionListener(listenerId); + console.log("Listener with id " + listenerId + " has been removed"); +} +catch (error) +{ + console.log("Error " + error.name + ": " + error.message); +} ++
Output example:
Listener with id 1 has been removed ++
Code example:
var option = { - interval: 10, - retentionPeriod: 1 + interval: 10, + retentionPeriod: 1 }@@ -1431,55 +1750,62 @@ For example, the anchorTime can be 1:00 am, January 1, 2000 or 1:00 am,
Code example:
function onerror(error) { - console.log(error.name + ": " + error.message); + console.log(error.name + ": " + error.message); } function onread(data) { - for (var idx = 0; idx < data.length; ++idx) - { - console.log("*** " + idx); - console.log('totalStepCount: ' + data[idx].totalStepCount); - } + for (var idx = 0; idx < data.length; ++idx) + { + console.log("*** " + idx); + console.log("max pressure: " + data[idx].max); + console.log("min pressure: " + data[idx].min); + console.log("average: " + data[idx].average); + } } -var type = 'PEDOMETER'; +var type = "PRESSURE"; var now = new Date(); -var startTime = now.setDate(now.getDate() - 7); +var startTime = now.setDate(now.getDate() - 4); var anchorTime = (new Date(2000, 1, 2, 6)).getTime(); var query = { - startTime: startTime / 1000, - anchorTime: anchorTime / 1000, - interval: 1440 /* 1 day */ + startTime: startTime / 1000, + anchorTime: anchorTime / 1000, + interval: 1440 /* 1 day */ }; + try { - tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror); + tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror); } catch (err) { - console.log(err.name + ': ' + err.message); + console.log(err.name + ": " + err.message); }
Output example:
*** 0 - totalStepCount: 3860 + max pressure: 1013.00 + min pressure: 930.00 + average: 980.00 *** 1 - totalStepCount: 6705 + max pressure: 1012.00 + min pressure: 954.00 + average: 986.00 *** 2 - totalStepCount: 4005 + max pressure: 950.00 + min pressure: 904.00 + average: 932.00 *** 3 - totalStepCount: 2328 + max pressure: 1012.00 + min pressure: 920.00 + average: 942.00 *** 4 - totalStepCount: 4705 - *** 5 - totalStepCount: 6446 - *** 6 - totalStepCount: 4103 - *** 7 - totalStepCount: 1456 + max pressure: 1012.00 + min pressure: 1005.00 + average: 1008.00
[NoInterfaceObject] interface GestureData { + readonly attribute GestureType type; + readonly attribute GestureEvent event; + readonly attribute long timestamp; + readonly attribute double? x; + readonly attribute double? y; + };+
+ Since: + 4.0 +
++ Since: + 4.0 +
++ Since: + 4.0 +
++ Since: + 4.0 +
++ Since: + 4.0 +
++ Since: + 4.0 +
+[Callback=FunctionOnly, NoInterfaceObject] interface GestureRecognitionCallback { + void onsuccess(GestureData data); + };+
+ Since: + 4.0 +
+onsuccess
+void onsuccess(GestureData data); +
+ Since: + 4.0 +
+Parameters:
++To guarantee that the gesture recognition application runs on a device with gesture recognition feature, declare the following feature requirement in the config file: +
+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:
Code example:
function onchangedCB(sleepInfo) { - console.log("Sleep status: " + sleepInfo.status); - console.log("Timestamp: " + sleepInfo.timestamp); + console.log("Sleep status: " + sleepInfo.status); + console.log("Timestamp: " + sleepInfo.timestamp); } tizen.humanactivitymonitor.start("SLEEP_MONITOR", onchangedCB); @@ -382,6 +411,74 @@ tizen.humanactivitymonitor.start("SLEEP_MONITOR", onchangedCB);
enum GestureType { "GESTURE_DOUBLE_TAP", "GESTURE_MOVE_TO_EAR", "GESTURE_NO_MOVE", "GESTURE_PICK_UP", + "GESTURE_SHAKE", "GESTURE_SNAP", "GESTURE_TILT", "GESTURE_TURN_FACE_DOWN", "GESTURE_WRIST_UP" };+
+ Since: + 4.0 +
+enum GestureEvent { "GESTURE_EVENT_DETECTED", "GESTURE_SHAKE_DETECTED", "GESTURE_SHAKE_FINISHED", "GESTURE_SNAP_X_NEGATIVE", + "GESTURE_SNAP_X_POSITIVE", "GESTURE_SNAP_Y_NEGATIVE", "GESTURE_SNAP_Y_POSITIVE", "GESTURE_SNAP_Z_NEGATIVE", "GESTURE_SNAP_Z_POSITIVE" };+
+ Since: + 4.0 +
+
Since:
@@ -516,20 +619,20 @@ The ErrorCallback method is launched with these error types:
Code example:
function onsuccessCB(pedometerInfo) { - console.log("Step status: " + pedometerInfo.stepStatus); - console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount); + 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); + 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); + 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); @@ -635,8 +738,8 @@ For other types, only 'http://tizen.org/privilege/healthinfo' should be dCode example:
function onchangedCB(pedometerInfo) { - console.log("Step status: " + pedometerInfo.stepStatus); - console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount); + console.log("Step status: " + pedometerInfo.stepStatus); + console.log("Cumulative total step count: " + pedometerInfo.cumulativeTotalStepCount); } tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB); @@ -651,26 +754,27 @@ tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB);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); - } + 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); + console.log("Error occurred. Name:" + error.name + ", message: " + error.message); } try { - tizen.humanactivitymonitor.start("GPS", onchangedCB, onerrorCB, {callbackInterval: 150000, sampleInterval: 1000}); + tizen.humanactivitymonitor.start("GPS", onchangedCB, onerrorCB, + {callbackInterval: 150000, sampleInterval: 1000}); } catch (err) { - console.log(err.name + ": " + err.message); + console.log(err.name + ": " + err.message); }
Code example:
function onchangedCB(pedometerInfo) { - console.log("Step status: " + pedometerInfo.stepStatus); - console.log("Accumulative total step count: " + pedometerInfo.accumulativeTotalStepCount); + console.log("Step status: " + pedometerInfo.stepStatus); + console.log("Accumulative total step count: " + pedometerInfo.accumulativeTotalStepCount); } tizen.humanactivitymonitor.setAccumulativePedometerListener(onchangedCB); @@ -907,23 +1011,23 @@ The ErrorCallback method is launched with this error type:@@ -1064,18 +1168,19 @@ catch (error)Code example:
function errorCallback(error) { - console.log(error.name + ': ' + error.message); + console.log(error.name + ": " + error.message); } function listener(info) { - console.log('type: ' + info.type); - console.log('timestamp: ' + info.timestamp); - console.log('accuracy: ' + info.accuracy); + console.log("type: " + info.type); + console.log("timestamp: " + info.timestamp); + console.log("accuracy: " + info.accuracy); } try { - var listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback); + var listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback); } catch (error) { - console.log(error.name + ': ' + error.message); + console.log(error.name + ": " + error.message); }@@ -975,25 +1079,25 @@ var listenerId; function errorCallback(error) { - console.log(error.name + ': ' + error.message); + console.log(error.name + ": " + error.message); } function listener(info) { - console.log('type: ' + info.type); - console.log('timestamp: ' + info.timestamp); - console.log('accuracy: ' + info.accuracy); + console.log("type: " + info.type); + console.log("timestamp: " + info.timestamp); + console.log("accuracy: " + info.accuracy); - tizen.humanactivitymonitor.removeActivityRecognitionListener(listenerId, errorCallback); + tizen.humanactivitymonitor.removeActivityRecognitionListener(listenerId, errorCallback); } try { - listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback); + listenerId = tizen.humanactivitymonitor.addActivityRecognitionListener("WALKING", listener, errorCallback); } catch (error) { - console.log(error.name + ': ' + error.message); + console.log(error.name + ": " + error.message); }
Code example:
-var type = 'PRESSURE'; +var type = "PRESSURE"; var options = { - retentionPeriod: 1 /* 1 hour */ + retentionPeriod: 1 /* 1 hour */ }; + try { - tizen.humanactivitymonitor.startRecorder(type, options); + tizen.humanactivitymonitor.startRecorder(type, options); } catch (err) { - console.log(err.name + ': ' + err.message); + console.log(err.name + ": " + err.message); }
Code example:
-var type = 'PRESSURE'; +var type = "PRESSURE"; try { - tizen.humanactivitymonitor.startRecorder(type); + tizen.humanactivitymonitor.startRecorder(type); + /* Do something */ - /* Do something */ - - tizen.humanactivitymonitor.stopRecorder(type); + tizen.humanactivitymonitor.stopRecorder(type); } catch (err) { - console.log(err.name + ': ' + err.message); + console.log(err.name + ": " + err.message); }
Code example:
function onerror(error) { - console.log(error.name + ": " + error.message); + console.log(error.name + ": " + error.message); } function onread(data) { - for (var idx = 0; idx < data.length; ++idx) - { - console.log('startTime: ' + data[idx].startTime); - console.log('endTime: ' + data[idx].endTime); - console.log('calories: ' + data[idx].calorie); - } + for (var idx = 0; idx < data.length; ++idx) + { + console.log("startTime: " + data[idx].startTime); + console.log("endTime: " + data[idx].endTime); + console.log("calories: " + data[idx].calorie); + } } -var type = 'PEDOMETER'; +var type = "PEDOMETER"; var query = {}; try { - tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror); + tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror); } catch (err) { - console.log(err.name + ': ' + err.message); + console.log(err.name + ": " + err.message); }@@ -1249,6 +1353,216 @@ catch (err) +
isGestureSupported
+boolean isGestureSupported(GestureType type); +
+ Since: + 4.0 +
++This function allows to check whether a gesture type is supported on the current device. Some gestures may not be supported on some devices because of lack necessary sensors. +
+Parameters:
+Return value:
+ boolean true if the given gesture type is supported. +Exceptions:
++ with error type TypeMismatchError, if input parameter is not compatible with the expected type. +
+ with error type AbortError, if any error occurs. +
Code example:
+try +{ + var isSupported = tizen.humanactivitymonitor.isGestureSupported("GESTURE_PICK_UP"); + console.log("GESTURE_PICK_UP is " + (isSupported ? "supported" : "not supported")); +} +catch (error) +{ + console.log("Error " + error.name + ": " + error.message); +} ++
Output example:
GESTURE_PICK_UP is supported. ++
addGestureRecognitionListener
+long addGestureRecognitionListener(GestureType type, GestureRecognitionCallback listener, optional ErrorCallback? errorCallback, optional boolean? alwaysOn); +
+ Since: + 4.0 +
++The ErrorCallback method is launched with this error type: +
+Parameters:
+Return value:
+ long The watch ID used to remove the listener. +Exceptions:
++ with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter. +
+ with error type NotSupportedError, if the gesture recognition is not supported. +
+ with error type IOError, if adding listener failed. +
Code example:
+function listener(data) +{ + console.log("Received " + data.event + " event on " + new Date(data.timestamp * 1000) + " for " + data.type + " type"); +} + +function errorCallback(error) +{ + console.log(error.name + ": " + error.message); +} + +try +{ + var listenerId = tizen.humanactivitymonitor.addGestureRecognitionListener("GESTURE_SHAKE", listener, errorCallback, true); + console.log("Listener with id " + listenerId + " has been added"); +} +catch (error) +{ + console.log("Error " + error.name + ": " + error.message); +} ++
Output example:
Listener with id 1 has been added + Received GESTURE_SHAKE_DETECTED event on Thu Sep 01 2016 14:33:56 GMT+0200 (CEST) for GESTURE_SHAKE type ++
removeGestureRecognitionListener
+void removeGestureRecognitionListener(long watchId); +
+ Since: + 4.0 +
+Parameters:
+Exceptions:
++ with error type AbortError, if system error occurs while removing listener. +
Code example:
+function listener(data) +{ + console.log("Received " + data.event + " event on " + new Date(data.timestamp * 1000) + " for " + data.type + " type"); +} + +function errorCallback(error) +{ + console.log(error.name + ": " + error.message); +} + +try +{ + var listenerId = tizen.humanactivitymonitor.addGestureRecognitionListener("GESTURE_SHAKE", listener, errorCallback); + tizen.humanactivitymonitor.removeGestureRecognitionListener(listenerId); + console.log("Listener with id " + listenerId + " has been removed"); +} +catch (error) +{ + console.log("Error " + error.name + ": " + error.message); +} ++
Output example:
Listener with id 1 has been removed ++
Code example:
var option = { - interval: 10, - retentionPeriod: 1 + interval: 10, + retentionPeriod: 1 }@@ -1436,55 +1750,62 @@ For example, the anchorTime can be 1:00 am, January 1, 2000 or 1:00 am,
Code example:
function onerror(error) { - console.log(error.name + ": " + error.message); + console.log(error.name + ": " + error.message); } function onread(data) { - for (var idx = 0; idx < data.length; ++idx) - { - console.log("*** " + idx); - console.log('totalStepCount: ' + data[idx].totalStepCount); - } + for (var idx = 0; idx < data.length; ++idx) + { + console.log("*** " + idx); + console.log("max pressure: " + data[idx].max); + console.log("min pressure: " + data[idx].min); + console.log("average: " + data[idx].average); + } } -var type = 'PEDOMETER'; +var type = "PRESSURE"; var now = new Date(); -var startTime = now.setDate(now.getDate() - 7); +var startTime = now.setDate(now.getDate() - 4); var anchorTime = (new Date(2000, 1, 2, 6)).getTime(); var query = { - startTime: startTime / 1000, - anchorTime: anchorTime / 1000, - interval: 1440 /* 1 day */ + startTime: startTime / 1000, + anchorTime: anchorTime / 1000, + interval: 1440 /* 1 day */ }; + try { - tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror); + tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror); } catch (err) { - console.log(err.name + ': ' + err.message); + console.log(err.name + ": " + err.message); }
Output example:
*** 0 - totalStepCount: 3860 + max pressure: 1013.00 + min pressure: 930.00 + average: 980.00 *** 1 - totalStepCount: 6705 + max pressure: 1012.00 + min pressure: 954.00 + average: 986.00 *** 2 - totalStepCount: 4005 + max pressure: 950.00 + min pressure: 904.00 + average: 932.00 *** 3 - totalStepCount: 2328 + max pressure: 1012.00 + min pressure: 920.00 + average: 942.00 *** 4 - totalStepCount: 4705 - *** 5 - totalStepCount: 6446 - *** 6 - totalStepCount: 4103 - *** 7 - totalStepCount: 1456 + max pressure: 1012.00 + min pressure: 1005.00 + average: 1008.00
[NoInterfaceObject] interface GestureData { + readonly attribute GestureType type; + readonly attribute GestureEvent event; + readonly attribute long timestamp; + readonly attribute double? x; + readonly attribute double? y; + };+
+ Since: + 4.0 +
++ Since: + 4.0 +
++ Since: + 4.0 +
++ Since: + 4.0 +
++ Since: + 4.0 +
++ Since: + 4.0 +
+[Callback=FunctionOnly, NoInterfaceObject] interface GestureRecognitionCallback { + void onsuccess(GestureData data); + };+
+ Since: + 4.0 +
+onsuccess
+void onsuccess(GestureData data); +
+ Since: + 4.0 +
+Parameters:
++To guarantee that the gesture recognition application runs on a device with gesture recognition feature, declare the following feature requirement in the config file: +
+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: