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 ?
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" >
As per your comments:
i'm talking about the default keyboard in android , i want to have the ability to disable / enable keyboard sound and vibration when user tap a key in keyboard,( like in Settings of Keyboard )
&
i'm talking about soft keyboard, like in SAMSUNG GALAXY S2 , HTC ONE ...etc
AFAIK, you can not accomplish this as each input method keeps its sound/vibration preference values internally. See for example Android (AOSP) IMe (as of this writing lines 30~39):
<CheckBoxPreference
android:key="vibrate_on"
android:title="@string/vibrate_on_keypress"
android:defaultValue="@bool/config_default_vibration_enabled"
android:persistent="true" />
<CheckBoxPreference
android:key="sound_on"
android:title="@string/sound_on_keypress"
android:defaultValue="@bool/config_default_sound_enabled"
android:persistent="true" />
As you can see it stores the vibrate/sound values in its shared preference. That applies to most of IMe in the market. Hence, you can not control vibrate/sound effect for all IMe's from single point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With