I am trying to make my device vibrate when I touch an object on Screen. I am using this code:
Vibrator v = (Vibrator) getSystemService(getApplicationContext().VIBRATOR_SERVICE);
v.vibrate(300);
with the permission in the manifest file but I don't seem to get any results. Any suggestions? Also, my hardware supports vibrate.
According to this answer, you can perform haptic feedback (vibrate) without asking for any extra permissions. Look at performHapticFeedback
method.
View view = findViewById(...)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
Note: I have not tested this code.