Deliverable 3

Goal: The objective here was to generate a simple event using Accelerometer.

Download Deliverable 3

Description of the event and the files

Initially we will assume that the phone is at rest on a surface. Hence the initial values of [x,y,z] will be [0,0,-1]. Then we will simulate an event that the phone is thrown and is falling down and gravitational force is acting on it. During the fall the [x,y,z] values will change rapidly to cause a change in the accelerometer values. When the phone is falling it will display an alert message. When the phone strikes the ground, the [x,y,z] values will come to rest and so will the accelerometer values. Again an alert message will be generated indicating that the phone has striked the ground. The values generated have also been 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 capturing and displaying the [x,y,z] values is coded in this file.

2) 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 button "throw the phone"

4) main2.xml - It is the UI file which will show the rapid cahnging values of of accelerometer corrsponding to [x,y,z] on screen.Also the alert messages will be displayed on this screen.

Screenshot of the code executing on the emulator

Fig 1. Figure below shows the initial UI screen with button "Throw the phone".
initial UI screen with button
Fig 2. Figure below shows the UI screen with accelerometer values for [x,y,z] and alert message of falling
accelerometer values for [x,y,z] and alert message of falling
Fig 3. Figure below shows the UI screen with accelerometer values and alert messsage when phone has striked ground
phone has striked ground and alert messsage
Fig 4. Figure below shows values written to the log file.
values written to the log file