Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
790 views
in Technique[技术] by (71.8m points)

android - enable/disable keyboard sound and vibration programmatically

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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" >

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...