Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Start sensors:
SensorManager mSensorManager = null;
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
int acc_sensorType = Sensor.TYPE_ACCELEROMETER;
int gyr_sensorType = Sensor.TYPE_GYROSCOPE;
Sensor acc_sensor = mSensorManager.getDefaultSensor(acc_sensorType);
Sensor gyr_sensor = mSensorManager.getDefaultSensor(gyr_sensorType);
mSensorManager.registerListener(this, acc_sensor, 1000000/Configuration.sampling_rate, SensorManager.SENSOR_DELAY_NORMAL);
mSensorManager.registerListener(this, gyr_sensor, 1000000/Configuration.sampling_rate, SensorManager.SENSOR_DELAY_NORMAL);
Read sensors data:
@Override
public void onSensorChanged(SensorEvent event) {
SensorDataSaver.saveSensorEvent(event.sensor,
System.currentTimeMillis(),
event.values[0], event.values[1], event.values[2]);
Save sensor data
(Using implementation 'commons-io:commons-io:2.6' - import org.apache.commons.io.FileUtils;)
if (sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
saveSensorData(accFile, timestamp, x, y, z);
} else {
saveSensorData(gyrFile, timestamp, x, y, z);