Good morning, I am developing an application on Android Nexus 7. I use the method event.getEventTime () and I noticed that the timestamps are not regularly spaced. There are large irregularities and, in some cases the difference between two timestamps is 0. I would need a regular spacing e.g. 10 or 100 milliseconds for subsequent processing. Is there a way to overcome this problem ? Thanks in advance for your suggestions.
I report below the piece of code that captures the parameters associated with the movement. I wonder why in the case of move the device does not collect data at regular sampling intervals
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
path.moveTo(eventX, eventY);
lastTouchX = eventX;
lastTouchY = eventY;
//----------------------------------
datiPunto[0] = String.valueOf(eventX);
datiPunto[1] = String.valueOf(eventY);
datiPunto[2] = String.valueOf(time);
datiPunto[3] = String.valueOf(event.getAction());
datiPunto[4] = "0";
datiPunto[5] = "0";
datiPunto[6] = String.valueOf(pressure);
CSVFileWriter.mem(datiPunto,tempDir, nome);
Log.i("worning","file csv memorizzato");
//----------------------------------
return true;
case MotionEvent.ACTION_MOVE:
resetDirtyRect(eventX, eventY);
int historySize = event.getHistorySize();
//float action = event.getAction();
for (int i = 0; i < historySize; i++) {
float historicalX = event.getHistoricalX(i);
float historicalY = event.getHistoricalY(i);
float historicalPressure = event.getHistoricalPressure(i);
long historicalTime = event.getHistoricalEventTime(i);
//----------------------------------
datiPunto[0] = String.valueOf(historicalX);
datiPunto[1] = String.valueOf(historicalY);
datiPunto[2] = String.valueOf(historicalTime);
datiPunto[3] = String.valueOf(event.getAction());
datiPunto[4] ="0";
datiPunto[5] = "0";
//datiPunto[4] = String.valueOf(action);
datiPunto[6] = String.valueOf(historicalPressure);
CSVFileWriter.mem(datiPunto,tempDir, nome);
Log.i("worning","file csv memorizzato");
//----------------------------------
expandDirtyRect(historicalX, historicalY);
path.lineTo(historicalX, historicalY);
} // close loop historical data
//----------------------------------
datiPunto[0] = String.valueOf(eventX);
datiPunto[1] = String.valueOf(eventY);
datiPunto[2] = String.valueOf(time);
datiPunto[3] = String.valueOf(event.getAction());
datiPunto[4] = "0";
datiPunto[5] = "0";
datiPunto[6] = String.valueOf(pressure);
CSVFileWriter.mem(datiPunto,tempDir, nome);
Log.i("worning","file csv memorizzato");
//----------------------------------
path.lineTo(eventX, eventY);
break;
case MotionEvent.ACTION_UP:
datiPunto[0] = String.valueOf(eventX);
datiPunto[1] = String.valueOf(eventY);
datiPunto[2] = String.valueOf(time);
datiPunto[3] = String.valueOf(event.getAction());
datiPunto[4] = "0";
datiPunto[5] = "0";
datiPunto[6] = String.valueOf(pressure);
CSVFileWriter.mem(datiPunto,tempDir, nome);
Log.i("worning","file csv memorizzato");
countPenUp++;
break;