Android CS323 Cornez
Lab 13: Sensors
Exercise 1: Detecting a Shake/Jerk Gesture
Construct an app that toggles a lightbulb on and off when the user shakes or jerks their device.

activity_main.xml
MyShakeListener.java
MainActivity.java
Exercise 2: Roaming Bee (or Ball) using the Accelerometer.
This app is created in the textbook Lab Example 8-1
-
Construct an application containing a bee (or the ball shown below). You can add TextViews to the main layout to provide accelerometer readings.

-
When the application first launches, the user is presented with the bee or ball
positioned at a specific x, y location on the screen.
-
The TextViews are helpful, as they display the x, y, and z-axis readings from the accelerometer.
- As the user tilts and rotates the device, the text fileds will be updatedto show the current accelerometer
readings.
- In addition, the ball will move in accordance with the tilt and roll of the device, as shown in the figure.
- The ball will not be allowed to roll off screen, and will be deterred by the virtual boundaries of the
screen.

Bee.java (or Ball.java)
MainActivity.java (Needs to be completed)
Exercise 3: Geomagnetic Rotation - Compass
.
Implement a geomagnetic rotation vector for measuring the orientation of
an Android device relative to a north, south, east, and west direction.
-
A geomagnetic rotation vector sensor is a composite sensor that will be defined by the
accelerometer in tandem with the magnetometer. The application may need to specify each feature
in a separate a uses-feature element within the Manifest file.
-
Indicate that motion readings will occur from an accelerometer and directional readings from a
magnetometer (compass) on the device.
- Set a portrait screen orientation for the application.
- Use your own art creation for the compass image.