Languages

Menu
Sites
Language
Problem getting hrm value with Human Activity Monitor after restarting gear s2

Hi guys
I'm encountering a strange problem with my simple gear s2 app. I use Human Activity Monitor api to constantly sample the heart rate. Each time I install the app from tizen IDE it works as expected but once I restart the watch and start the app without reinstalling, it doesn't work anymore while the screen is off. Meaning from that moment every time the screen goes off after a few seconds the heart rate updates stops as well. When I reinstall the app it works fine in the background again untill I restart the watch. I included background support in the xml and also use the tizen.power.request("CPU", "CPU_AWAKE") command. i'll appreciate any help with this issue.

Responses

1 Replies
Armaan-Ul- Islam

Hello,

The functionality you want to achieve most probably requires a service application.

<tizen:service id=[Service id] on-boot="true" auto-restart="true">

Please go through the documentations for details implementation:

Service Application

https://developer.tizen.org/development/guides/web-application/tizen-features/service-application

Service Application: Creating a Service Application

https://developer.tizen.org/development/api-tutorials/web-application/tizen-features/service-application

I am also sharing a demo that may help you start...

service.js

module.exports.onStart = function() {
        // init here
    console.log("Start Callback");
}

module.exports.onRequest = function() {
	//Code here
	console.log("Request Callback");
	
	try {
        //Read data from HRM Sensor//
	    }	
        catch(e) {
		console.log("Error: " + e.name + " Message: " + e.message);
	}
}

module.exports.onExit = function() {
	// Resource cleanup here
	console.log("Exit Callback");
}