如何关闭我所有的应用程序或活动的默认音效 [英] How to disable default sound effects for all my application or activity

查看:187
本文介绍了如何关闭我所有的应用程序或活动的默认音效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我使用的按键声音池点击音频效果。 问题是,如果在设备的设置声音选择打勾,然后我的按钮会产生两个声音:系统中的一个,我的一个在同一时间

In my application I am using sound pool for the button click audio effect. The problem is that if in the device's settings "Audible selection" is ticked, then my buttons will produce two sounds: the system one and my one at the same time.

看来,如果在每个按钮的属性我设置音效已启用设置为false,系统听不到声音了。但我有许多按钮在整个活动一打,再加上我加入的code按键矩阵,所以它是相当不方便手动设置启用音效为false,他们每个人。不知道我是怎么做到这一点的code ..

It seems that if in each button properties I set "Sound Effects Enabled" to false, the system sound is not heard any more. But I have many buttons across a dozen of activities, plus I am adding a matrix of buttons in code, so it is rather inconvenient to set "Sound Effects Enabled" to false manually for each one of them. Not sure how I do this in code..

有没有停止声音选择我的应用程序,或者至少在一个活动更具全球性的方式?

Is there a more global way to stop "Audible selection" in my application or at least for the one activity?

推荐答案

创建主题文件RES /价值/ styles.xml

Create a theme file "res/values/styles.xml"

<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="AppBaseTheme" parent="android:Theme.Black.NoTitleBar">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:soundEffectsEnabled">false</item>
</style>

</resources>

,然后引用它在你的的Andr​​oidManifest.xml

And then reference to it in your "AndroidManifest.xml"

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

这篇关于如何关闭我所有的应用程序或活动的默认音效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆