[ 
https://issues.apache.org/jira/browse/CB-9862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15110493#comment-15110493
 ] 

Sergey Grebnov commented on CB-9862:
------------------------------------

Just tried plugin version from master and it seems to work, here is console 
output (I've replaced alers with console to simplify debugging using Chrome 
inspect)

Here is my output:
{code}
Received Event: deviceready
index.js:59 watchID: 9f41de89-054d-5dbe-ba12-1d16268e478f
index.js:49 Acceleration X: -0.17138671875
Acceleration Y: 0.1468658447265625
Acceleration Z: 9.546737670898438
Timestamp: 1453377700745

index.js:59 watchID: c050eccd-0997-d217-80d3-8a84e6b8142d
index.js:49 Acceleration X: -0.1620941162109375
Acceleration Y: 0.1565399169921875
Acceleration Z: 9.513092041015625
Timestamp: 1453377704802

index.js:59 watchID: 779ae734-f5e7-3a0b-8177-cdddaaad5eae
index.js:49 Acceleration X: -0.1474609375
Acceleration Y: 0.1408233642578125
Acceleration Z: 9.519775390625
Timestamp: 1453377708746

index.js:59 watchID: 7cb2e9a6-d8c9-f7ec-d47d-369ded8f9b4e
index.js:49 Acceleration X: -0.139068603515625
Acceleration Y: 0.152923583984375
Acceleration Z: 9.5386962890625
Timestamp: 1453377712811

index.js:59 watchID: 8de34ab4-32d9-57e1-3ad9-0c13f708044e
index.js:49 Acceleration X: -0.186614990234375
Acceleration Y: 0.1446533203125
Acceleration Z: 9.52935791015625
Timestamp: 1453377716752

index.js:59 watchID: a12d056f-a042-6a65-1e25-82d3d5e58933
{code}

Here is my code:
{code}
onDeviceReady: function() {
    app.receivedEvent('deviceready');
    var watchID;
    var options = {
        frequency: 3000
    }
    // Update every 3 seconds
    function onSuccess(acceleration) {
        navigator.accelerometer.getCurrentAcceleration(onCurrent, onError); 
        navigator.accelerometer.clearWatch(watchID);
        setTimeout(start, 1000);
    }
    function onCurrent(acceleration)
    {
        console.log('Acceleration X: ' + acceleration.x + '\n' + 'Acceleration 
Y: ' + acceleration.y + '\n' + 'Acceleration Z: ' + acceleration.z + '\n' + 
'Timestamp: ' + acceleration.timestamp + '\n'); 
    }
    function onError()
    {
        alert('onError!');
    }

    function start()
    {
        watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, 
options);
        console.log('watchID: ' + watchID);
    }

    start();
},
{code}

> getCurrentAcceleration not working after clearWatch
> ---------------------------------------------------
>
>                 Key: CB-9862
>                 URL: https://issues.apache.org/jira/browse/CB-9862
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Device Motion
>    Affects Versions: 1.1.0
>            Reporter: Marian Hello
>              Labels: Android, triaged
>
> After navigator.accelerometer.clearWatch method call 
> navigator.accelerometer.getCurrentAcceleration is not calling callbacks.
> How to reproduce:
>     onDeviceReady: function() {
>         var watchID;
>         var options = { frequency: 3000 };  // Update every 3 seconds
>         function onSuccess(acceleration) {
>             navigator.accelerometer.getCurrentAcceleration(onCurrent, 
> onError);
>             navigator.accelerometer.clearWatch(watchID);
>             setTimeout(start, 1000);
>         }
>         function onCurrent(acceleration) {
>             alert('Acceleration X: ' + acceleration.x + '\n' +
>                   'Acceleration Y: ' + acceleration.y + '\n' +
>                   'Acceleration Z: ' + acceleration.z + '\n' +
>                   'Timestamp: '      + acceleration.timestamp + '\n');
>         }
>         function onError() {
>             alert('onError!');
>         }
>         function start() {
>             watchID = navigator.accelerometer.watchAcceleration(onSuccess, 
> onError, options);
>         }
>         start();
>     },



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to