Working with acclerometer
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get an instance to the accelerometer
this.sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
this.accelerometer = this.sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
}
@Override
public void onSensorChanged(SensorEvent event) {
// get the new point based on the readings from the accelerometer
SeismicDataPoint point = new SeismicDataPoint(this.framesCount++, event.values[this.currentAxisIndex]);
// add the point to a collection of all the points that should be visible on the screen
this.seismicActivityBuffer.add(point);
// draw the chart with all the points that should be visible*
this.chart = createChart(seismicActivityBuffer);
// keep the point in another collection, for historic purposes
this.allSeismicActivity.add(point);
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// Do nothing here.
}