Dates and General Information
Please start working on this well in advance. Even though you were given in class most of the difficult code you need, this is a time consuming assignment. It may take you 5-8 hours to complete it. Please look at the resources given at the bottom.
This is an assignment on services and sensors. You need to write an app that displays both the current acceleration to which the phone is subjected, and the strongest acceleration to which it has been subjected while the service is running. See the screen mock. The app works as follows. Read these instructions carefully.
- Use the linear accelerometer sensor. If you don't have it, it is ok to use the normal accelerometer (including gravity).
- The acceleration is defined by sqrt(ax * ax + ay * ay + az * az), where ax, ay, az are the accelerations on the three axes. That is, we use the modulus (magnitude) of the acceleration.
- When you develop or test, don't drop the phone; shaking it is safer, and actually better (gives larger readout).
- When the service starts running, it sets to 0 the maximum acceleration, and to undefined its time.
- While the service is running, the app continually measures the current acceleration, and updates the maximum acceleration and the time of maximum acceleration as needed.
- When the activity is started, it should start the service, unless the service is already running.
- Once the service is started, the activity should bind to it, and it should display a real-time feed of data from the service, indicating current acceleration, maximum acceleration measured by the service, and time of maximum acceleration.
- You don't need to display all values coming from the service, but try to display at least one value per second.
- When the user presses Reset, the activity tells the service to reset the maximum acceleration to 0, and the time of maximum acceleration to undefined.
- When the user presset Start/Stop:
- If the service is running, it is stopped.
- If the service is not running, it is started.
- Please display toasts that indicate when the service is started / stopped.
- When the user leaves the activity (e.g., by pressing on the Home button), the service is left running if it was running, and is left stopped if it is not running.
- Let's not be picky about the format you use for the date / timestamp. But, do include seconds into it, please.