Chris Pollett > Students >

    ( Print View )


    [Project Blog]

    [CS297 Proposal]

    [Deliverable 1]

    [Deliverable 2]

    [Deliverable 3]

    [Deliverable 4]


    [CS298 Proposal]




Deliverable 4

Goal: The objective here was to implement the Shake feature based on Accelerometer.

Download Deliverable 4

Description of the feature

The 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) - 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 file

2) - This class is called from 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 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

Fig 1. Figure below shows the initial UI screen with Textbox and connection Button.
TextBox and connection Button
Fig 2. Figure below shows the shaking of Sensor Simulator phone
shaking of Sensor Simulator phone
Fig 3. Figure below shows the empty text box due to shaking motion
shaking motion
Fig 4. Figure below shows the values written to the log file.
values written to the log file