我想将加速度值从js传递给java。谁能告诉我哪里错了?如何将JS代码中的值传递给Java中的JSNI
这里是我的代码:
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;
}-*/;
}
看到[这篇文章](http://stackoverflow.com/questions/9584991/how-to-instantiate-a-java-class-from-within-jsni)。 – 2012-08-15 09:44:26