How can I change programmatically a global setting like 'haptic feedback'?
(Manually you can change this setting in 'Sound & Display Settings')
Changing e.g. the airplane mode can be done with the following code:
private void setAirplaneMode(boolean bOn){ Settings.System.putInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, bOn ? 1 : 0); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", bOn ? 1 : 0); sendBroadcast(intent);}
However, for 'haptic feedback' this does not work because I don't find a corresponding intent.
Simply
private void setHapticFeedbackMode(boolean bOn){ Settings.System.putInt(getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, bOn ? 1 : 0);}
does not work (I guess a broadcast of an intent is really necessary).
I am not interested in things like setHapticFeedbackEnabled
, because in that way you are only changing the way how the calling app/view is handling haptic feedback.I am looking for a way to change the global setting. (Like if you were checking/unchecking the checkbox in 'Sound & Display Settings' manually.)