I have some buttons and need my phone vibrate on touch this buttons.
How I can do this?
Code of button for example
Button sushi = FindViewById<Button> (Resource.Id.sushiButton);
sushi.Click += delegate {
var intent24 = new Intent (this, typeof(SushiActivity));
StartActivity (intent24);
};
to vibrate, do this (assuming you are calling from within an Activity):
Vibrator vib = (Vibrator)this.GetSystemService(Context.VibratorService);
vib.Vibrate(50);
You will also need to enable this permission in your Manifest:
<uses-permission android:name="android.permission.VIBRATE"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.