Grant Vibration Permission
before you start implement code, you have to add permission in android manifest :
<uses-permission android:name="android.permission.VIBRATE"/>
Import Vibration Library
import android.os.Vibrator;
Get instance of Vibrator from Context
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
Check device has vibrator
void boolean isHaveVibrate(){
if (vibrator.hasVibrator()) {
return true;
}
return false;
}