3

I have a problem while trying to get the accelerometer data using the HTML 5 interface.

I declare this handler event:

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

to get the data provided by the accelerometer sensor. On the other hand, I have a function called as getMontionData:

    getMontionData = function (e)
    {           
        xAcceleration = e.acceleration.x;
        yAcceleration = e.acceleration.y;
        zAcceleration = e.acceleration.z;           
    }

to get the accelerometer data. The problem that I have is that the getMontionData function is not called when the device is locked or the screen is on black.

I'm doing this test on a smart watch using Tizen IDE and it is set this property

Could anybody explain me how to enable the application to get data even though the device is locked or the screen is on black?

While the application main window is displayed, the devicemotion event should be called since the getMontionData function is called. The problem happens, when the device screen is on black

Thank you so much

  • I am interested to do the same thing. Can you post more comprehensive code to help me along? I am new to HTML5 and Tizen... – robguinness Jun 10 '14 at 07:53

2 Answers2

2

Try adding this line to test if event gets triggered, if it does - find out why it's not being fired.

$(document).trigger('devicemotion'); 
Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265
1

Try adding the following setting to your config.xml as described in the documentation:

<tizen:setting background-support="enable" />

Without this the application can't run in the background, so the event doesn't work.

Paul S.
  • 1,583
  • 1
  • 11
  • 14