enable/disable keyboard sound and vibration programmatically

Houcine picture Houcine · May 6, 2013 · Viewed 15.3k times · Source

I'm trying to find a way to disable and enable keyboard sound and vibration when tapping keys. I've searched on Stack Overflow and other Android Forums but i didn't found any result.

I've tried AudioManager to enable vibrate mode, but i want to activate the vibrate mode and sound on keyboard.

audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, 
                AudioManager.VIBRATE_SETTING_ON);

Is there any way how to change android.provider.Settings for keyboard sound and vibration ?

Answer

Alexander Pacha picture Alexander Pacha · May 14, 2013

Have a look at How to disable default sound effects for all my application or activity for disabling tap-sounds.

To disable Haptic feedback and touch sounds programmatically have a look at http://developer.android.com/reference/android/view/View.html#setHapticFeedbackEnabled(boolean) http://developer.android.com/reference/android/view/View.html#setSoundEffectsEnabled(boolean)

Easier done is by defining the following in your styles.xml

<!-- Application theme. -->
<style name="AppTheme" parent="@android:style/Theme.NoTitleBar.Fullscreen">
    <item name="android:soundEffectsEnabled">false</item>
    <item name="android:hapticFeedbackEnabled">false</item>
</style>

and in your manifest.xml

<application [...] android:theme="@style/AppTheme" >