I'm developing an app for a personal project , and I will need to process the data later on on Matlab (for power requirements). Hence, my goal would be to "store" a value of the light sensor every two second, in an array ? Right now, I am able to correctly show the value of the sensor in real time, displayed on screen based on the default frequency of the smartphone ! I'm quite novice in Android, and I'm learning everyday haha ! I'm just stuck there... The final goal would be to send the data to a database and create a graph of it later on .. showing the light intensity of a place in term of time .. What would be the best storage please? Best regards,
private final SensorEventListener LightSensorListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
if(event.sensor.getType() == Sensor.TYPE_LIGHT){
textLight_reading.setText("LIGHT : " + event.values[0]);
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
};
And here is the other part of the code :
textLight_available = (TextView) findViewById(R.id.LIGHT_available);
textLight_reading = (TextView) findViewById(R.id.LIGHT_reading);
SensorManager mySensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
Sensor LightSensor = mySensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
super.onResume();
if (LightSensor != null) {
textLight_available.setText("LIGHT SENSOR ON");
mySensorManager.registerListener(LightSensorListener, LightSensor,
SensorManager.SENSOR_DELAY_NORMAL);
} else {
textLight_available.setText("LIGHT SENSOR OFF");
}