Tuesday, 4 June 2013

How to do Vibration in Windows Phone using C# code

How to do Vibration in Windows Phone using C# code



Step 1 : First create your windows phone application it's may be 7.0,7.1,8.0 application.

Step2: Open MainPage.xaml code file .

Step 3 : Import below code file.

 using Microsoft.Devices;

Step 4 :Declare one VibrateController object

VibrateController vc = VibrateController.Default;

Step 5 : Add button to start vibration.

<Button Content="Vibration" Grid.Row="1" Height="72" HorizontalAlignment="Left"  Name="btnVibration" VerticalAlignment="Top" Width="160" Click="btnVibration_Click" />

 Step 6 : Add code behind to add button click event

private void btnVibration_Click(object sender, RoutedEventArgs e)
        {

           //specify the time span specify time below 5 second this is maximum limitation of vibration.
            vc.Start(TimeSpan.FromSeconds(1));
        }


Step 7 :  You can stop vibration using object Stop() method.

  vc.Stop();


Step 4 : This way you can get  use vibrate services in windows phone.



No comments:

Post a Comment

Thank you for your interest .