Languages

Menu
Sites
Language
Device Motion event is not always triggered

I'm developing an application for the Gera2 Neo smartwatch. When I press a button, the application should read continuously the accelerometer data. The problem I have is that the devicemotion event is not always triggered.

I use this statement to add the handler event:

window.addEventListener("devicemotion",getMontionData,true);

While the application main window is displayed, the devicemotion event is triggered. In this case, it works properly. The problem is raised when the device screen goes on black or when I press the hw-back-key. Then, the getMontionData function is not called. It seems like the devicemontion event was not triggered.

So, could anyone help me how to resolve it? So, I would like is that the devicemotion was continuously triggering even though the screen is on black or I press the hw-back-key and the getMotionData function was called

getMontionData = function (e)
        {            
            xAcceleration = e.acceleration.x;
            yAcceleration = e.acceleration.y;
            zAcceleration = e.acceleration.z;
            console.log("x: " + xAcceleration);
            console.log("y: " + yAcceleration);
            console.log("z: " + zAcceleration);
        }

to get the acceleration data.

I also set up the background setting (<tizen:setting background-support="enable"/>)

Thank so much,

 

Álvaro

 

 

Responses

6 Replies
Gökhan Kurt

I have the very same problem. I am trying to handle it by keeping CPU and SCREEN on with these calls:

tizen.power.request("CPU", "CPU_AWAKE");
tizen.power.request("SCREEN", "SCREEN_DIM");

It helps to some extent until user clicks hardware key end puts the device into screen off state again. Then I get no more motion events.

Would appreciate if some one found a solution?

Gökhan Kurt

I kind of found a half tricky half bugy solution to this one.

Run these two whenever you get an event

 tizen.power.request("CPU", "CPU_AWAKE");
 tizen.power.request("SCREEN", "SCREEN_DIM");

This causes the screen to be turned on and stay on and you then continue to get events.

If users presses the home button and put device in standby mode tha events are stopped.

But from time to time events are anyway generated even though screen is off (At least pedometer events) Or the user looks at her watch by turning the wrist which again causes the device to turn on the screen at which time events are again generated and above code is run and put the device in the same screen always on state continuing to generate events as usual.

Rob Guinness

I'm also looking for a robust solution to this. I would like to record accelerometer data in the background, regardless of the state of the applicaiton. Please report if anyone finds such solutions!

ChiehHsin Chen

I want to do exactly the same things and try to find a solution for many days

When the screen is on black, cannot listen deviceMotion anymore!!!!

Hopes this could improve or gear2 is useless for my research :(

Jake Lee

Is there any one to find a solution for this matter?  Could we turn on sensor data events as background service?

It seems the only option so far is turn on the screen all the time but it might not be the real solution.

Genovese

I have exactly the same problem (on my Samsung Gear 2) depicted by Alvaro.

I need to acquire signals coming from accelerometer and gyroscope even if the the screen goes off.

The solution of course exists (the Pedometer application works well) but quite surprisingly a lot of forums have just addedd noise to the issue.

Has anyone found a solution?