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)
   {
      // This exception is thrown in the emulator-which doesn’t support an accelerometer.
      isActive = false;
   }

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.