multithreading - How to print accelerometer values every X seconds in Android -
I want to print the accelerometer value every 3 seconds This is my code so far
Override public @SensorChanged @ SenseorChanged {// TODO auto generated method stub if (event.sensor.getType () == sensor.Tep_ACCLARMAMM} {X = one * x + (1 - A) * event. Values [0]; Y = one * y + (1 - a) * event.values [1]; Z = one * z + (1 - A) * event.values [2]; New handler () Post Delayed (New Runnabel) {@Override public void run () {printValue ();}}, 3000); }} Production is delayed only when Outlook is launched, what is my fault and how to solve it?
You need to remove your handler from onSensorChanged () It will run continuously Now you will only have to execute if you have any changes in your sensor reading. In addition, you need to add a call to run again to run again, otherwise it will only be executed once. // External sensor (outside of converted), maybe new handler (on) in-activity of your activity Postdilid (New Runnabal) ({Override Public Wide Run)} {printValue (); New Handler (). Post Delayed (This, 3000);}}, 3000);
Comments
Post a Comment