Motion Detection - Tuong-Nguyen/PreparationEduLog GitHub Wiki

Requirement

There are events which need to be sent to server while the vehicle is in motion or not, such as:

  • Send IN_MOTION event when the vehicle is currently moving
  • Send NO_MOTION_BEGIN event while the vehicle begin a physical stop. ...

And some actions can happen when the vehicle changes the motion state (ie: NO_MOTION -> IN_MOTION, ...) :

  • Turn off tablet screen

Therefore, we need to research solutions for motion detection

Expectation

  • Find out at least 2 options for the solution.
  • Point out the pros and cons of each solution.
  • Choose an option and the reason why.

Proposed Solutions:

Google Play services location APIs

We should use this solutions because:

Pros:

  • According to Google document, this is recommended way of adding location awareness to our app
  • Provide handy way to detect current speed (not tested yet): Location.getSpeed()
  • High accuracy

Cons:

  • Require data connection, GPS enabled to work properly

Android framework location APIs

Pros:

  • Provide handy way to detect current speed (not tested yet): Location.getSpeed()
  • High accuracy

Cons:

  • Require data connection, GPS enabled to work properly

Note: Both frameworks support update current location after specific period of time, see GoogleApi's LocationRequest#setInterval and Android location framework's LocationManager#requestLocationUpdates for more details

Use Accelerometer sensor

Pros:

  • No need of data connection and GPS

Cons:

  • Sensor framework only provide raw data (displacement, time), we need to do some math and physics to calculate speed at a specific time
  • Low accuracy