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" />
Paresh Mayani

Lazy android developer, exploring the horizon of android development since 7 years, currently working as a Technical Lead - Android at Simform Solutions, India. Former Application Architect at KarConnect. He is the Head/Organizer of Google Developers Group (GDG), Ahmedabad

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