AccelerometerFailedException in windows phone 7

Accelerometer aSensor = new Accelerometer();   // Add the accelerometer event handler to the accelerometer sensor aSensor.ReadingChanged += new EventHandler<AccelerometerReadingEventArgs>(AccelerometerReadingChanged);   bool isActive = false; // Start the accelerometer try { aSensor.Start(); isActive = true; } catch (AccelerometerFailedException e) { // the accelerometer couldn’t be started. isActive = false; } catch (UnauthorizedAccessException e) { // […]
Continue reading…

Enjoyed this post? Share it!

 
 

State of accelerometer sensor in windows phone 7

There are six possible values for the SensorState enumeration: Disabled Initiating NoData NoPermissions NotSupported Ready The Accelerometer.Start() method should be called only if the accelerometer is in a ready state. To get the current state, use the Accelerometer.State property.
Continue reading…

Enjoyed this post? Share it!

 
 

Reading accelerometer data in windows phone 7

Add a reference to the Microsoft.Devices.Sensors assembly, and declare an instance of the Accelerometer class. Call the Start() method to generate accelerometer readings. using Microsoft.Devices.Sensors;   Accelerometer accelerometer = new Accelerometer(); accelerometer.Start(); accelerometer.ReadingChanged += new EventHandler<AccelerometerReadingEventArgs>(accelerometer_ReadingChanged); The event handler void accelerometer_ReadingChanged(object sender, AccelerometerReadingEventArgs e) { float X = (float)e.X; float Y = (float)e.Y; float Z […]
Continue reading…

Enjoyed this post? Share it!