Android,使用硬件指南针
我找不到关于 Android 硬件指南针的太多信息。我一直在尝试设置我的标准来强制 Android 使用硬件指南针。基本上我的问题是我希望即使设备静止时轴承也能更新。
据我了解,GPS 只会在您移动时更新您的方位。无论您是否搬家,我都愿意更新。我尝试通过将速度设置为常数 10 来欺骗设备,使其认为它正在移动,但轴承始终返回 0.0。
我的测试设备(当前)是 HTC Tattoo。它有一个指南针,所以这不是问题。所以我的问题是,有没有办法使用硬件罗盘来更新方位?不管你搬还是不搬?
I can't find much information out there on Android's hardware compass. I keep trying to setup my criteria to force Android to use the hardware compass. Basically my problem is I want the bearing to update even while the device is stationary.
From my understanding the GPS will only update your bearing when your moving. I'd like bearing to update regardless if you're moving or not. I've tried tricking the device in to thinking it's moving by setting the speed at a constant 10 but the bearing returns 0.0 always.
My device for testing (currently) is a HTC Tattoo. It has a compass so that's not the problem. So my question is, is there a way to get the bearing to update using hardware compass or not? regardless if your moving or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您看过这个示例代码吗?这里使用
SensorListener
来查询方向:好的,所以这是已弃用的代码。现在 SensorManager 有一个可以使用的
getOrientation()
方法。但这确实需要一个旋转矩阵。请参阅此处举个例子。Have you seen this example code? Here a
SensorListener
is used to query the orientation:Ok, so this is deprecated code. Now the SensorManager has a
getOrientation()
method that can be used. This does need a rotation matrix though. See here for an example.