Chris Pollett >
Students > [Bio] |
Deliverable 4Goal: The objective here was to implement the Shake feature based on Accelerometer. Description of the featureThe basic principle of shake feature is that if a user wants to delete something that he previously entered then he can do it by shaking the phone. He does not have to explicitly use a 'back' button or a 'clear' key. For implementing this feature i had a simple UI consisting of a Textbox. The user enters something into the Textbox and then he connects to the Sensor Simulator jar application. When the user shakes the graphical image of the phone in the sensor simulator, the data in the Textbox is cleared. When the phone is shaken the accelerometer values generated are tested against a threshold value. If these values are greater than the threshold then it is detected as a 'shake' motion. The values generated are written to a log file to help in debugging the code. 1) Test.java - It is the class which is initially executed and which connects to Sensor Simulator. The functionality for detecting the shake motion and capturing the [x,y,z] values during shaking of the phone is coded in this file. These values are also written to the log file2) AccelerometerReader.java - This class is called from test.java and it basically enables the sensors on the phone. It also tests for a particular sensor (Accelerometer in our case) and enables it. The accelerometer values corresponding to [x,y,z] are generated in this class and the result is passed to the Test.java class where they are displayed. 3) main.xml - It is the UI file which shows the TextBox where user can enter some data and the connection button for connecting to the sensor simulator Screenshot of the code executing on the emulator
|