Search code examples
androidlisteneraccelerometershake

How to stop accelerometer sensor


I am using exactly this code in this example

http://android.themind-lab.com/post/2010/05/14/Dont-shake-my-phone!-How-to-detect-shake-motion-on-Android-phone.aspx

What should i include in MyMethod() to stop the listener and don`t wait for another shake after MyMethod() is called the first time?

Thanks


Solution

  • The line

    sensorMgr.unregisterListener(this);

    will make the system stop sending you onSensorChanged updates