We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
Android 模拟器本身不支持它,但 OpenIntents 的 SensorSimulator 填补了这一空白。下载并解压 zip 文件,然后启动独立的 jar 文件:
接下来,使用 SDK 附带的 adb 工具在模拟器上安装 SensorSimulatorSettings:(
运行 adb devices 以查找模拟器设备名称)。最后,在模拟器中运行已安装的 SensorSimulatorSettings 应用程序并输入 IP 地址 10.0.2.2(不管 SensorSimulator 应用程序可能会建议什么)。这是开发主机的环回设备的别名,因此应始终为有效的。
The Android emulator doesn't support it itself but OpenIntents' SensorSimulator fills the void. Download and unpack the zip file, then start the standalone jar file:
Next, install SensorSimulatorSettings on the emulator using the adb tool which comes with the SDK:
(run adb devices to find the emulator device name). Finally, run the installed SensorSimulatorSettings app in the emulator and enter the IP address 10.0.2.2 (despite what the SensorSimulator application might suggest. This is an alias to the loopback device of the development host so should always be valid.
最新版本的模拟器启用了加速度计和其他传感器模拟支持。可以
telnet localhost 5554
:,我不知道到底如何模拟震动。尝试快速地一个接一个地发送这两个命令:
The recent version of emulator comes enabled with Accelerometer and other sensor simulation support. One can
telnet localhost 5554
:How exactly to simulate a shake, I don't know. Try sending these two commands one after the other rapidly:
我也试图让 SensorSimulator 工作,我想我终于让它工作了。
上述步骤:
"...java -jar bin/sensorsimulator.jar
接下来,使用 SDK 附带的 adb 工具在模拟器上安装 SensorSimulatorSettings:
$ adb -s install bin/SensorSimulatorSettings.apk
...最后,在模拟器中运行已安装的 SensorSimulatorSettings 应用程序并输入 IP 地址 10.0.2.2...”
是一个好的开始,但我需要做更多。
您显然需要然后修改您的应用程序以使用 SensorSimulator。您可以访问 http://code。 google.com/p/openintents/wiki/SensorSimulator 并向下滚动到“如何在应用程序中使用 SensorSimulator”部分。
即便如此,我在编译时也遇到了一些错误,因此您可能想查看此页面: Android 模拟器上的老式温度计组件 + SensorSimulator< /a> - 我必须删除对 android.hardware.Sensor、SensorEvent 和 SensorEventListener 的引用,
然后在调用 connectSimulator 时失败。显然,我需要在清单文件中授予我的应用程序使用互联网的权限。 。
毕竟,我可以使用 SensorSimulator 虚拟旋转我的手机,并且我确实在应用程序中获得了相应的传感器读数。
I also was trying to get the SensorSimulator working and I think I finally got it working.
The above steps:
"...java -jar bin/sensorsimulator.jar
Next, install SensorSimulatorSettings on the emulator using the adb tool which comes with the SDK:
$ adb -s install bin/SensorSimulatorSettings.apk
...Finally, run the installed SensorSimulatorSettings app in the emulator and enter the IP address 10.0.2.2..."
are a good start, but I needed to do more.
You apparently need to then modify your application to use the SensorSimulator. You can go to http://code.google.com/p/openintents/wiki/SensorSimulator and scroll down to the "How to use the SensorSimulator in your application" section.
Even then I got some errors in compiling, so you might want to see this page: Vintage Thermometer component + SensorSimulator on the Android emulator - I had to remove the references to android.hardware.Sensor, SensorEvent, and SensorEventListener.
And then it was failing at the call to connectSimulator. Apparently, I needed to give my application permission to use the Internet in the manifest file.
After all that, I am able to use the SensorSimulator to virtually rotate my phone and I do get the corresponding sensor readings in my application.
我发现目标 10 的模拟器不支持加速度计,但目标 15 的模拟器支持。不知道有没有办法实现目标10。
因此,为了测试您的应用程序,请为目标 15 创建项目和 AVD。
I experienced that emulator for target 10 doesn't support accelerometer but for target 15 it does. I dont know if there is a way to do it for target 10.
So for testing your application, Create your project and AVD for target 15.
我建议您使用 Genymotion 应用程序,它集成了用于测试加速度计的完整工具并使用更快的模拟器:Genymotion
I suggest you to use Genymotion application, it integrate a complete tool for the test of accelerometer and use a faster emulator: Genymotion