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

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -