How to use Sensor Simulator in Android SDK Emulator
In this post we will simulate various sensors such as accelerometer, compass, orientation and temperature sensor using SensorSimulator in Android SDK Emulator.
The OpenIntents SensorSimulator lets you simulate sensor data with the mouse in real time, where the behavior can be customized through various settings. It currently supports four sensors only but more are being developed by their team.
First you need to download the latest stable version of SensorSimulator. Go to their download page and then search for the latest sensorsimulator-x.x.x.zip file and download it. Right now the they have released the beta version and you can download it from here.
Note:
- Here we will be working on Android Platform 1.5.
- We have assumed that Android SDK's location in Windows is "E:\android-sdk-windows\". If you have installed/unzipped your SDK somewhere else, you can change this base-path accordingly in the rest of the tutorial.
Once you have downloaded the latest version of SensorSimulator uncompress it and go inside the bin folder. Here you will find two files sensorsimulator.jar and SensorSimulatorSettings.apk. Copy the sensorsimulator.jar file inside the tools directory of the Android SDK folder i.e. E:\android-sdk-windows\tools\.
Now we need to install the SensorSimulatorSettings.apk in Android SDK Emulator. You can read this tutorial if you need help with the installation of SensorSimulatorSettings.apk file. Follow the steps given in that tutorial and once you have installed we can proceed further.
Note: The above mentioned tutorial is for Android Platform 1.5 but it will work for other Android Platforms also.
Once you have installed the SensorSimulatorSettings.apk in Android Emulator click on the Launcher icon (emulator must be running right now and if not boot/start it up) as shown below.
A list of applications will appear now and Sensor Simulator setting application will be present in it. Open it.
Now minimize the Android Emulator and open command terminal inside Windows by going to Start>>Run>>cmd. Inside command terminal change your current working directory to E:\android-sdk-windows\ and execute the following command as shown below.
java -jar sensorsimulator.jar
The moment you execute the above mentioned command sensorsimulator.jar will be launched.
Now enter the IP address in the Android Emulator as shown in SensorSimulator window.
After this select the Testing tab and then click on Connect as shown below.
Once you click on Connect button the Android Emulator will connect itself with Sensor Simulator (in Windows). Now a list of sensors will appear below Connect button. You need to Enable these sensors by selecting the checkbox present before each sensor name. They are disabled by default.
Once you enable them the sensor data will synchronize itself as shown below.
And now if you try to change position and orientation of the figure in the Sensor Simulator (in Windows) the values of all sensors will change accordingly in the Android Emulator. Thats it! We are done.