Shake Detection algorithm for android