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:
mSensorManager.registerListener(mSensorListener,
mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SensorManager.SENSOR_DELAY_UI);
and this to unbind it:
mSensorManager.unregisterListener(mSensorListener);