我在这个例子中就使用了这段代码。
http://android.themind-lab.com/post/2010/05/14/Dont-shake-my-phone!-How-to-detect-shake-motion-on-Android-phone.aspx
在第一次调用MyMethod()之后,我应该在MyMethod()中包含什么才能停止侦听器而不等待另一次摇动?
谢谢
发布于 2011-08-08 22:10:39
这条线
sensorMgr.unregisterListener(this);
将使系统停止向您发送onSensorChanged更新
发布于 2014-06-12 02:22:09
终于找到了答案:
这还不足以注销监听器,还需要将SensorEventListener设置为null
sensorMgr.unregisterListener(this);
msensorlistener = null;这招很管用,
希望能有所帮助。
https://stackoverflow.com/questions/6983306
复制相似问题