Hello.
I'm develping an app on Andoird and I'm stuck on adding Values from a sensor to an arrayList.
The sensor is working good because it shows my in the Log. But the (ArrayList) al.Size() = 0.

Code:

  ArrayList<Float> aL = new ArrayList<Float>();
    sm SensorManger = (SensorManager) getSystemService(SENSOR_SERVICE);



    public void onCreate(Bundle savedInstanceState) {

    runSenor();

    ...///SOME CODE OVER HERE///...

    }

        @Override
        public void onSensorChanged(int sensor, float[] values) {
        aL.add(values[1]);
        Log.d("Log", "Accel Y: "+ values[1])
        }

        public void runSensor(){

            sm.registerListener(this, 
                    SensorManager.SENSOR_ACCELEROMETER,
                    SensorManager.SENSOR_DELAY_UI);

        }
        public void stopSensor(){

            sm.unregisterListener(this);

        }

Does any body knows what I'm doing worg ?
Thank you for any help
Regards

I see no issues there. If you can have your project on Github or similar just post a link, otherwise without seeing rest of the code it is unlikely someone may be able to help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.