In my settings menu i have used a switch when i turn it on i want every button in-app to vibrate and when i turn the switch off i want every button in-the app to not vibrate.
The following is the code i have tried so far.
switch2!!.setOnCheckedChangeListener { buttonView, isChecked ->
if (switch2!!.isChecked) {
switch2!!.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
else {
vibrator.cancel()
}
}