我想在Android中获取移动设备的当前定位。我可以使用OrientationEventListener检测方向更改。但这只有在方向发生变化时才有效。当方向改变时,我想做点什么。但出于某种目的,如果移动设备在桌面上并且没有方向改变,我需要知道我当前的方向。通过一些谷歌搜索,我发现sersormanager.getorientation和sensormanager.getRotationMatrix可用于此目的。但我无法在代码中实现它。任何人都可以提供一些代码来获得我目前的学位导向吗?
答案 0 :(得分:0)
正如您所说,您应该看一下SensorManager。
http://developer.android.com/reference/android/hardware/SensorManager.html
这是一个很好的示例,请查看onAccuracyChanged():