Hey
this doesn’t work on my android device (Android 5.0 / EMUI 3.1)
The alert does not pop up, or anything else in the onSuccess function.
Anyone knows why?
.controller('DiagWinkelACtrl', function($scope) {
$scope.myDeg = 90;
// READY
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
function onDeviceReady() {
navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
}
// onSuccess: Get a snapshot of the current acceleration
function onSuccess(acceleration) {
alert('Acceleration X: ' + acceleration.x + '\n' +
'Acceleration Y: ' + acceleration.y + '\n' +
'Acceleration Z: ' + acceleration.z + '\n' +
'Timestamp: ' + acceleration.timestamp + '\n');
}
// onError: Failed to get the acceleration
function onError() {
alert('onError!');
}
})