美文网首页
Android sound effects设置

Android sound effects设置

作者: DD_Dog | 来源:发表于2020-01-09 16:41 被阅读0次

安卓设置中有UI touch的提示音,在按下物理按键的时候也会出现。
设置和获取的方法:

//设置 0-关闭,1-打开
Settings.System.putInt(getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED, 0);

//获取
int enabled = Settings.System.getInt(getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED);

播放代码位于framework/base/media/java/android/media/AudioManager.java

public void  playSoundEffect(int effectType) {
    if (effectType < 0 || effectType >= NUM_SOUND_EFFECTS) {
        return;
    }

      if (!querySoundEffectsEnabled()) {
          return;
      }

    IAudioService service = getService();
    try {
        service.playSoundEffect(effectType);
    } catch (RemoteException e) {
        Log.e(TAG, "Dead object in playSoundEffect"+e);
    }
}

相关文章

网友评论

      本文标题:Android sound effects设置

      本文链接:https://www.haomeiwen.com/subject/jsoyactx.html