I would like to customize the delay time used here. If SENSOR_DELAY_NORMAL is used then the delay is about .2 seconds (200,000 microseconds). I would like the delay to be around .35 seconds. The delay doesn't have to be exact, just greater than .2 seconds and less than .4. Any suggestions how I would go about that? Min API is 15.
protected void onResume() {
super.onResume();
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
}
You can set your desired delay freely beside these four default values, however, it is not guaranteed. Example call:
mSensorManager.registerListener(this, mAccelerometer, 100);
# 100 microsecond is the desired delay between two events here.
# you can change it to whatever value suits you.
It only works API level 9 onwards according to Android documentation.
Details:
boolean registerListener (SensorEventListener listener,
Sensor sensor,
int samplingPeriodUs)
samplingPeriodUs
int: The rate sensor events are delivered at. This is only a hint to the system. Events may be received faster or slower than the specified rate. Usually events are received faster. The value must be one of SENSOR_DELAY_NORMAL, SENSOR_DELAY_UI, SENSOR_DELAY_GAME, or SENSOR_DELAY_FASTEST or, the desired delay between events in microseconds. Specifying the delay in microseconds only works from Android 2.3 (API level 9) onwards. For earlier releases, you must use one of the SENSOR_DELAY_ constants.*
You can read this for the details. https://developer.android.com/reference/android/hardware/SensorManager.html