0

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;
vince
  • 11
  • 3
  • Please post some code to better help understanding the application environment. – JScoobyCed Oct 24 '13 at 08:24
  • And BTW, this event capture motion of the device, so events will be triggered at the rhythm the motion is executed, for example to capture acceleration. So unless you can physically move the device at a very precise rhythm, you won't get regular time spaces between events (even if you can do that, the device might still need a few micro-seconds to process stuff so time spaces won't be regular) – JScoobyCed Oct 24 '13 at 08:33

0 Answers0