Wednesday, June 25, 2014

How to make your Windows Phone app vibrate?

There are 2 simple ways to make your Windows Phone app vibrate the device.

The first method makes use of the VibrateController class in the Microsoft.Devices namespace:

            VibrateController vibrateController = VibrateController.Default;

The second method makes use of the VibrationDevice class in the Windows.Phone.Devices.Notification namespace:

            VibrationDevice vibrationDevice = VibrationDevice.GetDefault();

In both these instances, the vibration will automatically stop after the amount passed as TimeSpan has elapsed.

You can call the corresponding Stop or Cancel method of the class to stop the vibration before the TimeSpan passed has elapsed.

Paras Wadehra
Microsoft MVP
Twitter: @ParasWadehra

No comments: