3

I´m working with sensor accelerometer and i wonder if it´s possible and how to run two things in onSensorChanged. 1. i want to Accelerometer data x,y,z allways store in the field 2. if shake is detect, run another activity

My question is, when shake is detect and run another activity, i still want to store x,y,z in my fields. How can i do that?

 @Override
public void onSensorChanged(int sensor, float[] values) {
    // TODO Auto-generated method stub

    x = values[0];
    y = values[1];
    z = values[2];
    ....
 ThreadForLoopA threatA = new ThreadForLoopA(x,y,z);
 ThreadForLoopB threatB = new ThreadForLoopB();
   ....
  threatA.run();
  threatB.run();

X,y,z are changing all the time and i get just the first x,y,z data in my threadA class.

Is possible to create threads inside onSensorChanged? Hope someone understant what i´m trying to do :) Thanks

1 Answer 1

3

A thread is started with start, not run. run will just call the method sequentially on the main thread.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.