コード例 #1
0
 /*
  * (non-Javadoc)
  *
  * @see de.unikassel.android.sdcframework.devices.AbstractAndroidSensorDevice#
  * doHandleSensorChanged(android.hardware.SensorEvent)
  */
 @Override
 public final synchronized void doHandleSensorChanged(SensorEvent event) {
   if (event.values != null && event.values.length == 3) {
     currentSampleData.setAccelerationX(event.values[0]);
     currentSampleData.setAccelerationY(event.values[1]);
     currentSampleData.setAccelerationZ(event.values[2]);
     hasSample = true;
   }
 }
コード例 #2
0
 /*
  * (non-Javadoc)
  *
  * @see de.unikassel.android.sdcframework.devices.AbstractAndroidSensorDevice#
  * getCurrentSampleData()
  */
 @Override
 protected final synchronized SampleData getCurrentSampleData() {
   Logger.getInstance()
       .info(
           this,
           "x="
               + currentSampleData.getAccelerationX()
               + "; y="
               + currentSampleData.getAccelerationY()
               + "; z="
               + currentSampleData.getAccelerationZ());
   return currentSampleData;
 }
コード例 #3
0
  /**
   * Constructor
   *
   * @param context the application context
   */
  public AccelerometerDevice(Context context) {
    super(
        SensorDeviceIdentifier.Accelerometer,
        Sensor.TYPE_ACCELEROMETER,
        context,
        SensorManager.SENSOR_DELAY_GAME);

    this.currentSampleData = new AccelerometerSampleData();
    currentSampleData.setAccelerationX(Float.MIN_VALUE);
    currentSampleData.setAccelerationY(Float.MIN_VALUE);
    currentSampleData.setAccelerationZ(Float.MIN_VALUE);
    hasSample = false;
  }