mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-30 00:00:04 +08:00
Getting Accelerometer working. Beep fails for an unknown reason.
This commit is contained in:
+3
-3
@@ -10,9 +10,9 @@
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceInfo = function(){
|
||||
document.getElementById("platform").innerHTML = Device.platform;
|
||||
document.getElementById("version").innerHTML = Device.version;
|
||||
document.getElementById("uuid").innerHTML = Device.uuid;
|
||||
document.getElementById("platform").innerHTML = Device.getPlatform();
|
||||
document.getElementById("version").innerHTML = Device.getVersion();
|
||||
document.getElementById("uuid").innerHTML = Device.getUuid();
|
||||
}
|
||||
|
||||
var getLocation = function() {
|
||||
|
||||
+26
-1
@@ -81,7 +81,7 @@
|
||||
*/
|
||||
|
||||
Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallback, options) {
|
||||
this.getCurrentAcceleration(successCallback, errorCallback, options);
|
||||
navigator.accelerometer.getCurrentAcceleration(successCallback, errorCallback, options);
|
||||
// TODO: add the interval id to a list so we can clear all watches
|
||||
var frequency = (options != undefined)? options.frequency : 10000;
|
||||
return setInterval(function() {
|
||||
@@ -602,4 +602,29 @@ Geolocation.prototype.clearWatch = function(watchId)
|
||||
Geo.stop(watchId);
|
||||
}
|
||||
|
||||
/* Identical to the iPhone, except we have to create this in the JS */
|
||||
|
||||
_accel = {}
|
||||
_accel.x = 0;
|
||||
_accel.y = 0;
|
||||
_accel.z = 0;
|
||||
|
||||
function gotAccel(x,y,z)
|
||||
{
|
||||
_accel.x = x;
|
||||
_accel.y = y;
|
||||
_accel.z = z;
|
||||
}
|
||||
|
||||
Accelerometer.base_method = Accelerometer.prototype.watchAcceleration
|
||||
Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallback, options)
|
||||
{
|
||||
Accel.start();
|
||||
Accelerometer.base_method(successCallback, errorCallback, options);
|
||||
}
|
||||
|
||||
Accelerometer.prototype.clearWatch = function(watchId){
|
||||
clearInterval(watchId);
|
||||
Accel.stop();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user