Android – Vibrate the phone programmatically

By -



Hi,

I came across to making phone vibrate when user change the orientation from portrait to landscape or viceversa.

So How do we make phone vibrate programatically in android?

Code:

// vibration for 800 milliseconds
((Vibrator)getSystemService(VIBRATOR_SERVICE)).vibrate(800);

Required permission to add inside the AndroidManifest.xml file:

<uses-permission android:name="android.permission.VIBRATE" />

CEO & Co-Founder at SolGuruz® | Organiser @ GDG Ahmedabad | Top 0.1% over StackOverflow | 15+ years experienced Tech Consultant | Helping startups with Custom Software Development

Loading Facebook Comments ...
Loading Disqus Comments ...