Thanks to stackoverflow.
Add this to manifest.
<uses-permission android:name="android.permission.VIBRATE"/>
Then in code
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); long[] vibrationPattern = {0, 500, 50, 300}; //-1 - don't repeat final int indexInPatternToRepeat = -1; vibrator.vibrate(vibrationPattern, indexInPatternToRepeat);
If you don’t need a pattern then you can simply specify a duration in milliseconds.
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); vibrator.vibrate(100);