1

How to use a button to toggle the accelerometer on/offf?

view story
linux-howto

http://stackoverflow.com – I have been working on logging data from accelerometer. Nonetheless, I find it difficult to control the on/off of the accelerometer sensor. I have tried to have two buttons, one called Start and the other Stop. I initialized my senor object in the onCreate() callback of the Activity Class. Then in the onClick() callback for the buttons, I checked the id of the View, if it's Start button, I registerListen for the sensor, if it's stop, I unregister it. This does not work as expected. And onSensorChanged(), I simply display the x,y, z accelerations. The sensor does what it needs to do no matter w (HowTos)