code: private boolean isAccelerating(SensorEvent event) {
      float ax = event.values[0];
      float ay = event.values[1];
      float az = event.values[2];
  
      // Instead of comparing magnitude to ACCELERATION_THRESHOLD,
      // compare their squares. This is equivalent and doesn't need the
      // actual magnitude, which would be computed using (expensive) Math.sqrt().
      final double magnitudeSquared = ax * ax + ay * ay + az * az;
      return magnitudeSquared > accelerationThreshold * accelerationThreshold;
    }
docs: Returns true if the device is currently accelerating.