我如何可以模拟加速度计在Android模拟器?加速度计、模拟器、Android

2023-09-12 01:41:54 作者:回忆的沙漏

我没有Android手机现在。但是,在我的应用程序需要使用加速度计值。所以,我需要一个能成为一个模拟器。我怎样才能做到这一点?

I don't have an Android phone right now. But in my application I need to use the accelerometer values. So I need an a simulator capable of it. How can I do this?

推荐答案

Android模拟器不支持它本身,而是OpenIntents软件的 SensorSimulator 填补的空白。下载并解压缩zip文件,然后启动独立jar文件:

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:

$ java -jar bin/sensorsimulator.jar

接下来,安装使用亚行的工具,它自带的SDK模拟器上的SensorSimulatorSettings:

Next, install SensorSimulatorSettings on the emulator using the adb tool which comes with the SDK:

$ adb -s <emulator device> install bin/SensorSimulatorSettings.apk

(运行的 ADB设备的找到模拟器设备名称)。最后,运行在模拟器中安装SensorSimulatorSettings应用程序,并输入IP地址 10.0.2.2 (不管什么SensorSimulator应用程序可能暗示,这是一个别名发展主机的回环设备,以便始终应有效的。

(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.