Billie Billie - 1 year ago 85
Java Question

How to make an Android device vibrate?

I wrote an Android application. Now, I want to make the device vibrate when a certain action occurs. How can I do this?

Answer Source


 import android.os.Vibrator;
 Vibrator v = (Vibrator) this.context.getSystemService(Context.VIBRATOR_SERVICE);
 // Vibrate for 500 milliseconds


Don't forget to include permission in AndroidManifest.xml file:

<uses-permission android:name="android.permission.VIBRATE"/>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download