Android的重力感应(TYPE_GRAVITY)2.1 [英] Android gravity sensor (TYPE_GRAVITY) for 2.1
问题描述
我的软件专为2.3.3,我现在用的是重力感应器。
I have software designed for 2.3.3 where I am using the gravity sensor.
低于code -
Code below -
private SensorManager sman = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
private Sensor magnetfield, gravity;
...
magnetfield = sman.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
gravity = sman.getDefaultSensor(Sensor.TYPE_GRAVITY);
我决定加入支持2.1版本。然而似乎TYPE_GRAVITY不支持2.1,我也得到一个错误, Sensor.TYPE_GRAVITY
不再被认可。
问题解答 - A)当我搜索的Android重力感应器2.1谷歌的链接,视频,演示重力感应器在2.1的设备。这是否意味着有一种方法来访问它? b)如果不是,那是什么可以用这个最低的版本?无法找到它的SDK。
Questions - A) When I search for "Android gravity sensor 2.1" googles links to videos that demo gravity sensor in 2.1 devices. Does that mean there is a way to get access to it? B) If not, what is the lowest version that can use this? Couldn't find it in the SDK.
感谢
推荐答案
通过查看源$ C $ C,你可以看到,重力感应器是利用巴特沃斯滤波器实际计算。我也问DSP的一个问题(这里)。希望链接帮助,因为它让我明白了很多东西。
By looking at the source code you can see that the gravity sensor is actually computed using a Butterworth filter. I also asked a question on dsp (here). Hope the link helps because it helped me understand quite a lot of things.
有关问题的版本:其中重力感应器; 2.3你需要实现自己的过滤器,如果你想相同的结果。
For gravity sensor in versions < 2.3 you need to implement that filter yourself if you want the same results.
<一个href="http://gitorious.org/rowboat/frameworks-base/blobs/671a6ff4be11b3e2d8eb017e0c7a78e6133fb2b8/services/sensorservice/SecondOrderLowPassFilter.cpp">Here在2.3中使用的源$ C $ C
Here is the source code used in 2.3
后来编辑:增加了一个有效的链接
Later edit: Added a valid link!
这篇关于Android的重力感应(TYPE_GRAVITY)2.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!