gcoleman0828
gcoleman0828

Reputation: 1542

Windows Phone 8.1 Accelerometer detecting a shake

I having problems finding documentation or examples regarding the proper way to use the Accelerometer to trigger a Shake event. Seems like it should be easy, but all the examples are 8.0 which apparently are using Microsoft.Devices.Sensors;

Apparently you are supposed to use using Windows.Devices.Sensors; which you would think are the same, but things like Start() and Stop methods no longer exist. I was trying to use a Microsoft AccelerometerHelper class from Microsoft and it also uses the older namespace. The Shaken event in the Accelerometer class is only triggered on the tablets and not phones according to:

MSDN : here

Windows Phone 8: The accelerometer sensor does not raise the Shaken event on the Windows Phone 8 platform. If you add an event handler for the Shaken event in your Windows Phone 8 app, no error is raised, but the code in the event handler won’t run.

Upvotes: 2

Views: 959

Answers (1)

truongnm
truongnm

Reputation: 2474

The last resort or another option if you can't port the code to WP 8.1 Runtime is to switch the project to Windows Phone 8 Silverlight or even 8.1 Silverlight, all code work perfectly, I've worked with AccelerometerHelper class before and face the same problem.

Upvotes: 3

Related Questions