Tuesday, 20 October 2009

Android emulator: simulating the sensor inputs

On it's own the android emulator cannot simulate physically moving the device, but with additional software we can emulate movement and position of a physical Android device. The software that we'll need to do this is called Sensor simulator and can be downloaded from here.

Download this zip file and unpack it. In the bin directory is a file called sensorsimulator.jar. Just click on this and it will run the sensor simulator application that will allow you to control the movement of you virtual device. You'll also need to install the SensorSimulatorSetting.apk on your emulator and set the IP address that is shown in the sensor simulator app. To install the .apk file use this command:

adb install \bin\SensorSimulatorSettings.apk

Once you have everything installed and running, you can manipulate the orientation of you virtual phone in the sensor simulator application just by rotating the wire frame representation of the mobile phone. The sensors that are currently supported are the accelerometer, compass and orientation sensors, additionally there is also support for a temperature sensor.

To use the sensor simulator in you application takes a few simple changes to the code, which are outline here. Once this is done you can now test out your application that uses sensor data in you emulator, a much quicker process than loading it onto an actual android phone.

There's more instructions on the Sensor simulator web site, but it's all straight forward and you should be able to virtually control the orientation of you emulator in no time.