关闭

Android打开关闭触摸提示音

标签: 触摸提示音
741人阅读 评论(0) 收藏 举报
分类:

1.启动应用程序的时候关闭系统的触摸声音

public void DisTouchEffectAndSaveState() {
SharedPreferences setting = this.getSharedPreferences("SystemSetting", MODE_PRIVATE);
int mSoundEffect = setting.getInt("SOUND_EFFECTS_ENABLED", -1);

if (mSoundEffect == -1) {
SharedPreferences.Editor editor = setting.edit();
mSoundEffect = Settings.System.getInt(this.getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED, 0);

editor.putInt("SOUND_EFFECTS_ENABLED", mSoundEffect);
editor.commit();
}


AudioManager mAudioManager = (AudioManager) getSystemService(Service.AUDIO_SERVICE);
mAudioManager.unloadSoundEffects();
Settings.System.putInt(this.getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED, 0);
}

2.退出应用的时候恢复原来设置

public void RecoveryTouchEffect() {
SharedPreferences setting = this.getSharedPreferences("SystemSetting", MODE_PRIVATE);
int mSoundEffect = setting.getInt("SOUND_EFFECTS_ENABLED", 0);
AudioManager mAudioManager = (AudioManager) getSystemService(Service.AUDIO_SERVICE);
Settings.System.putInt(this.getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED, mSoundEffect);
mAudioManager.loadSoundEffects();
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1946次
    • 积分:63
    • 等级:
    • 排名:千里之外
    • 原创:4篇
    • 转载:4篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档