How to detect that the phone (WP7) has stopped sha

2019-05-29 18:52发布

I can get the phone to react to a shake, but what is the best way to tell that it has stopped shaking?

2条回答
再贱就再见
2楼-- · 2019-05-29 19:14

This example worked for me.

At the very bottom of the page you'll see:

                if (!_shaking && CheckForShake(_lastReading, reading, ShakeThreshold) && _shakeCount >= 1)
                {
                    //We are shaking
                    _shaking = true;
                    _shakeCount = 0;
                    OnShakeDetected();
                }
                else if (CheckForShake(_lastReading, reading, ShakeThreshold))
                {
                    _shakeCount++;
                }
                else if (!CheckForShake(_lastReading, reading, 0.2))
                {
                    _shakeCount = 0;
                    _shaking = false;
                }
查看更多
爷、活的狠高调
3楼-- · 2019-05-29 19:17

Do like #Daniel Pereira said, but in the void ShakeDetected(object sender, EventArgs e) use a Dispatcher.BeginInvoke(() => youMethod()); and do what you pretend to do in youMethod(). I know this post is a little old but now other people can know how it resolve

查看更多
登录 后发表回答