The Android Sensors Simulator PRO

The android platform supports various hardware sensors with which our application can interact. These sensors include (among others) a sensor for the outside temprature, an accelerometer, a compas and a sensor for getting the device orientation.

The current standard android emulato bundled with the android SDK doesn’t allow us testing applications that use these sensors.

I have recently found the Sensor Emulator, an open source project developed by Open Intents. Following few technical difficulties I had during the process of running this solution on my desktop I chose to write down this post and pack all the files I used in one zip file. Make sure you visit the official download page and make sure your usage of these files meets with the license terms. I make those files available in accordance with that license in a separated zil file just in order to simplify the work on your end.

The first step should be downloading the files I packed in one zip file. Extracting this zip file you will find the following files:
sensorsimulator.jar
sensorsimulatorsetting.zip
sensordemo.zip

The second step should be running the stand alone application. Just double click the sensorsimulator.jar file. Assuming you already have the JRE installed on your desk top that application will start running. You will use this application in order to change the values the sensors should get when using them in your code.

The third step should be running the Sensor Simulator android application. You can find that application project packed within the sensorsimulatorsetting.zip file. Extract this file and then start a new android project using the eclipse development environment, choose ‘ceate project from existing source’, select the folder and make sure to write 4 as the min sdk version required for this project. Once this project is opened on your eclipse development environment, just install its apk on your emulator. Make sure to use an android virtual device configured with the android sdk version 1.6. The Sensor Simulator android application you have just installed on your android virtual device will allow you to test the sensorsimulator.jar you have already started (second step).

The fourth step would be testing the sensorssimulator.jar application. In order to do it we first need to verify the IP number and the port number the Sensor Simulator android application should try to connect. The sensorssimulator.jar allows you to set a port number to work with. Try to set a number that works. If the sensorssimulator.jar cannot work with the port number you choose you will get a message saying so. During my work with sensorssimulator.jar I succeeded to set the port 8020. The sensorssimulator.jar also shows the possible IP number. When running the Sensor Simulator android application just make sure to set these IP and port numbers and try to connect. The ‘Setting’ tab allows setting the IP and the port number. The ‘Testing’ tab allows pressing the ‘Connect’ button in order to connect with the sensorssimulator.jar application, that we already have up and running on our desktop. Press the ‘Connect’ button and get to see how the two apps (the one running on the desktop and the one running on the emulator) are connected with each. Try to change the values feeded to the sensors by playing with the sensorssimulator.jar application and see how the application you are now running on the android platform senses those changes.

  

The fifth step would using this simulator tool when testing an application you develop on your own. In order to do that I recommend you to follow the short code sample packed within the sensordemo.zip file.

The official resource for more information about this tool can be found at http://code.google.com/p/openintents/wiki/SensorSimulator.

Please note that the SensorSimulator still uses the SDK 1.0 API that was already declared as deprecated. The SDK 1.5 and 2.0 use a new API that still support SDK 1.0.


All files available as part of this post were developed by Open Intents and their usage is subject to the license terms available on their web site at www.openintents.org.

Share:

The Visitor Design Pattern

The Visitor Design Pattern

The visitor design pattern allows us to add operations to objects that already exist without modifying their classes and without extending them.

What are Anti Patterns?

Anti Patterns

Unlike design patterns, anti patterns just seem to be a solution. However, they are not a solution and they cause additional costs.

Virtual Threads in Java Professional Seminar

Virtual Threads in Java

The use of virtual threads can assist us with improving the performance of our code. Learn how to use virtual threads effectively.

NoSQL Databases Courses, Seminars, Consulting, and Development

MongoDB Design Patterns Meetup

The use of MongoDB involves with various cases in which we can overcome performance issues by implementing specific design patterns.

image of woman and database

Record Classes in Java

Learn how to define record classes in Java, and when to use record classes in your code. Stay up to date with the new Java features.

Accessibility | Career | Conferences | Design Patterns | JavaScript | Meetups | PHP | Podcasts | Python | Self Learning

Teaching Methodologies | Fullstack | C++ | C# | CSS | Node.js | Angular | Java | Go | Android | Kotlin | Swift | Academy

Front End Development | Scala | Architectures | Cloud | Big Data | Internet of Things | Kids Learn Programming

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Skip to content Update cookies preferences