I have implemented Shake Event listener in my application and onShake do some logic. I want to show a dialog after the user has stopped shaking the phone. Where do I need to implement this logic? If I do it onShake itself then multiple dialogs will appear. Can someone help me?
Thanks
Jai
so, thinking about your problem, i was initially considering to “tweak” the constant values of your listener (MIN_FORCE, MIN_TIME… etc) in order to create some “resistance” for the event, so it wouldn’t be fired excessively. Then i realized it was a stupid idea, since there is a much better solution… just unbind the event handler when the shake event occurs, and then re-bind it when the user dismisses the dialog. To do this, use the same code provided in the answer you used for the onResume and onPause methods:
this to bind the listener:
and this to unbind it: