我想将加速度的值从 js 传递给 java。谁能告诉我哪里错了?
这是我的代码:
public class Accelerometer extends JavaScriptObject {
protected Accelerometer(){};
public static native double getCurrentAccelerationX() /*-{
var x = 0.0;
$wnd.ondevicemotion = function(event){
//$wnd.alert(event.accelerationIncludingGravity.x);
x = event.accelerationIncludingGravity.y;
};
return x;
}-*/;
}